Skip to content

Commit

Permalink
Change escape key to only cancel selector popups/command line in norm…
Browse files Browse the repository at this point in the history
…al mode
  • Loading branch information
Nimaoth committed Aug 15, 2024
1 parent e5f0957 commit ab8e4b9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
20 changes: 20 additions & 0 deletions config/keybindings_vim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -875,12 +875,32 @@ proc loadVimKeybindings*() {.expose("load-vim-keybindings").} =
addTextCommandBlockDesc "", "<C-e>", "exit to normal mode":
editor.selection = editor.selection
editor.setMode("normal")

addTextCommandBlockDesc "", "<ESCAPE>", "exit to normal mode and clear things":
if editor.mode == "normal":
editor.selection = editor.selection
editor.clearTabStops()
editor.setMode("normal")

addCommandBlockDesc "command-line-low", "<ESCAPE>", "exit to normal mode and clear things":
if getActiveEditor().isTextEditor(editor):
if editor.mode == "normal":
exitCommandLine()
return

editor.clearTabStops()
editor.setMode("normal")

addCommandBlock "popup.selector", "<ESCAPE>":
if getActiveEditor().isTextEditor(editor):
if editor.mode == "normal":
if getActivePopup().isSelectorPopup(popup):
popup.cancel()
return

editor.clearTabStops()
editor.setMode("normal")

addTextCommandBlockDesc "", ".", "replay commands": replayCommands(".")
addCommand "editor.text.normal", "@<CHAR>", "<CHAR>", proc(editor: TextDocumentEditor, c: string) =
let register = if c == "@":
Expand Down
4 changes: 4 additions & 0 deletions scripting/absytree_runtime.nim
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,10 @@ template addCommandBlock*(context: string, keys: string, body: untyped): untyped
addCommand context, keys, proc() =
body

template addCommandBlockDesc*(context: string, keys: string, desc: string, body: untyped): untyped =
addCommandDesc context, keys, desc, proc() =
body

func getContextWithMode*(context: string, mode: string): string =
if mode.len == 0 or mode[0] == '#':
return context & mode
Expand Down

0 comments on commit ab8e4b9

Please sign in to comment.