Fix #850: Dodgy yy

I don't quite understand how it worked at all without focusing the commandline first.

Peppered code with some more awaits as part of debugging and couldn't be bothered to test which were necessary.
This commit is contained in:
Oliver Blanthorn 2018-07-26 10:17:46 +01:00
parent c3d0ef60c8
commit 756c29673a
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
2 changed files with 7 additions and 4 deletions

View file

@ -336,7 +336,7 @@ function applyWithTmpTextArea(fn) {
}
}
export function setClipboard(content: string) {
export async function setClipboard(content: string) {
applyWithTmpTextArea(scratchpad => {
scratchpad.value = content
scratchpad.select()
@ -346,7 +346,7 @@ export function setClipboard(content: string) {
} else throw "Failed to copy!"
})
// Return focus to the document
Messaging.message("commandline_background", "hide")
await Messaging.message("commandline_background", "hide")
}
export function getClipboard() {

View file

@ -2192,7 +2192,10 @@ export async function yank(...content: string[]) {
async function setclip(str) {
// Functions to avoid retyping everything everywhere
let s = () => Native.clipboard("set", str)
let c = () => messageActiveTab("commandline_frame", "setClipboard", [str])
let c = async () => {
await messageActiveTab("commandline_content", "focus")
await messageActiveTab("commandline_frame", "setClipboard", [str])
}
let promises = []
switch (await config.getAsync("yankto")) {
@ -2206,7 +2209,7 @@ async function setclip(str) {
promises = [s(), c()]
break
}
return Promise.all(promises)
return await Promise.all(promises)
}
/** Fetches the content of the clipboard/selection buffer depending on user's preferences