mirror of
https://github.com/vale981/tridactyl
synced 2025-03-05 17:41:40 -05:00
Fix #2088: restore automatic exit from visual mode
You can toggle this with the visualexitauto setting.
This commit is contained in:
parent
7510fb32fe
commit
65033343ae
2 changed files with 15 additions and 9 deletions
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Add table
Reference in a new issue