Skip to content

Commit

Permalink
SImplyfy focus management BetterThanTomorrow#161
Browse files Browse the repository at this point in the history
  • Loading branch information
PEZ committed Jun 4, 2019
1 parent a62c168 commit 652639a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Binary file modified alpha-build/clojure4vscode-2.0.0-SNAPSHOT.vsix
Binary file not shown.
22 changes: 9 additions & 13 deletions webview-src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ con.addCompletionListener(e => {
});

document.addEventListener("DOMContentLoaded", () => {
con.input.focus();
document.body.appendChild(completionDiv);
document.body.appendChild(docDiv);
})
Expand Down Expand Up @@ -155,29 +154,26 @@ function setCompletionIndex(idx: number) {
message.postMessage({ type: "info", ns: ns, symbol: completions[selectedCompletion] });
}

let dontFocus = false;
// let dontFocus = false; // This is not needed atm and only messes things up

window.addEventListener("mousedown", e => {
dontFocus = false;
// dontFocus = false;
})

window.addEventListener("mouseup", e => {
if (!dontFocus)
setTimeout(() => { // WHOA: This is an ugly workaround for focus glitching
con.input.focus();
}, 100);
con.input.focus();
})

window.addEventListener("focus", e => {
setTimeout(() => { // WHOA: This is an ugly workaround for focus glitching
con.input.focus();
}, 100);
con.input.focus();
})

document.addEventListener("selectionchange", e => {
if (document.getSelection().rangeCount != 0)
dontFocus = true;

// This does not seem to be called as we think it would
// if (document.getSelection().rangeCount != 0)
// dontFocus = false;
})

window.addEventListener("keydown", e => {
if (e.keyCode == 68 && e.ctrlKey) {
message.postMessage({ type: "interrupt" });
Expand Down

0 comments on commit 652639a

Please sign in to comment.