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 => { document.addEventListener("selectionchange", () => {
if (v === "false") return const selection = document.getSelection()
document.addEventListener("selectionchange", () => { if ((contentState.mode == "visual") && (config.get("visualexitauto") == "true") && (selection.anchorOffset == selection.focusOffset)) {
if (contentState.mode !== "normal") return contentState.mode = "normal"
const selection = document.getSelection() return
if (selection.anchorOffset !== selection.focusOffset) { }
contentState.mode = "visual" 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 // 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`. * Whether to enter visual mode when text is selected. Visual mode can always be entered with `:mode visual`.
*/ */
visualenterauto: "true" | "false" = "true" visualenterauto: "true" | "false" = "true"
/**
* Whether to return to visual mode when text is deselected.
*/
visualexitauto: "true" | "false" = "true"
} }
/** @hidden */ /** @hidden */