Fix #2088: restore automatic exit from visual mode

You can toggle this with the visualexitauto setting.
This commit is contained in:
Oliver Blanthorn 2020-01-12 12:44:37 +00:00
parent 7510fb32fe
commit 65033343ae
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
2 changed files with 15 additions and 9 deletions

View file

@ -357,15 +357,16 @@ config.getAsync("leavegithubalone").then(v => {
}
})
config.getAsync("visualenterauto").then(v => {
if (v === "false") return
document.addEventListener("selectionchange", () => {
if (contentState.mode !== "normal") return
const selection = document.getSelection()
if (selection.anchorOffset !== selection.focusOffset) {
contentState.mode = "visual"
}
})
document.addEventListener("selectionchange", () => {
const selection = document.getSelection()
if ((contentState.mode == "visual") && (config.get("visualexitauto") == "true") && (selection.anchorOffset == selection.focusOffset)) {
contentState.mode = "normal"
return
}
if ((contentState.mode !== "normal") || (config.get("visualenterauto") == "false")) return
if (selection.anchorOffset !== selection.focusOffset) {
contentState.mode = "visual"
}
})
// Listen for statistics from each content script and send them to the

View file

@ -990,6 +990,11 @@ export class default_config {
* Whether to enter visual mode when text is selected. Visual mode can always be entered with `:mode visual`.
*/
visualenterauto: "true" | "false" = "true"
/**
* Whether to return to visual mode when text is deselected.
*/
visualexitauto: "true" | "false" = "true"
}
/** @hidden */