Skip to content

Commit 3ade19a

Browse files
committed
Cancel completions if escaped backslash is typed (#1656)
Fixes #1655 This commit adds a key binding to actively cancel auto completions, if escaped backslash `\\` is typed, which indicates a manual "newline". It prevents unwanted completions from being inserted, if enter is pressed. Note: A key binding is used as `cancelCompletion` rule doesn't provide reliable behavior, especially if `\\` is typed in the middle of a sentence.
1 parent f304f5d commit 3ade19a

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

Default (Linux).sublime-keymap

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ LaTeX Package keymap for Linux
6666
// TODO: remove ctrl+l,ctrl+space
6767
// ------------------------------------------------------------------
6868

69+
// Cancel Completions, if escaped backslash, aka. newline, is typed
70+
// note: ST's cancelCompletion doesn't handle it well.
71+
{
72+
"keys": ["\\"],
73+
"command": "chain",
74+
"args": {
75+
"commands": [
76+
{"command": "hide_auto_complete" },
77+
{"command": "insert", "args": {"characters": "\\"} }
78+
]
79+
},
80+
"context": [
81+
{ "key": "auto_complete_visible" },
82+
{ "key": "selector", "operand": "text.tex" },
83+
{ "key": "preceding_text", "operator": "regex_contains", "operand": "(?<!\\\\)(\\\\{2})*\\\\$" }
84+
]
85+
},
86+
6987
{
7088
"keys": ["ctrl+l","ctrl+space"],
7189
"command": "latextools_fill_all",

Default (OSX).sublime-keymap

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ LaTeX Package keymap for OS X
6666
// TODO: remove cmd+l,ctrl+space
6767
// ------------------------------------------------------------------
6868

69+
// Cancel Completions, if escaped backslash, aka. newline, is typed
70+
// note: ST's cancelCompletion doesn't handle it well.
71+
{
72+
"keys": ["\\"],
73+
"command": "chain",
74+
"args": {
75+
"commands": [
76+
{"command": "hide_auto_complete" },
77+
{"command": "insert", "args": {"characters": "\\"} }
78+
]
79+
},
80+
"context": [
81+
{ "key": "auto_complete_visible" },
82+
{ "key": "selector", "operand": "text.tex" },
83+
{ "key": "preceding_text", "operator": "regex_contains", "operand": "(?<!\\\\)(\\\\{2})*\\\\$" }
84+
]
85+
},
86+
6987
{
7088
"keys": ["super+l","ctrl+space"],
7189
"command": "latextools_fill_all",

Default (Windows).sublime-keymap

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ LaTeX Package keymap for Linux
6666
// TODO: remove ctrl+l,ctrl+space
6767
// ------------------------------------------------------------------
6868

69+
// Cancel Completions, if escaped backslash, aka. newline, is typed
70+
// note: ST's cancelCompletion doesn't handle it well.
71+
{
72+
"keys": ["\\"],
73+
"command": "chain",
74+
"args": {
75+
"commands": [
76+
{"command": "hide_auto_complete" },
77+
{"command": "insert", "args": {"characters": "\\"} }
78+
]
79+
},
80+
"context": [
81+
{ "key": "auto_complete_visible" },
82+
{ "key": "selector", "operand": "text.tex" },
83+
{ "key": "preceding_text", "operator": "regex_contains", "operand": "(?<!\\\\)(\\\\{2})*\\\\$" }
84+
]
85+
},
86+
6987
{
7088
"keys": ["ctrl+l","ctrl+space"],
7189
"command": "latextools_fill_all",

0 commit comments

Comments
 (0)