Skip to content

Commit 14e5a03

Browse files
committed
Require at least one character after backslash
1 parent 2674f19 commit 14e5a03

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/unicode-helper.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ export const unicodeHelperWith = (pairs: Pair[]) => (editor: Editor): Hints => {
1010
const to = editor.getCursor();
1111
const str = editor.getLine(to.line).slice(0, to.ch);
1212
const from = { line: to.line, ch: str.lastIndexOf("\\") };
13-
const typed = editor.getRange(from, to);
13+
// Exclude the backslash when searching
14+
const typed = editor.getRange({ line: from.line, ch: from.ch + 1 }, to);
1415
return {
1516
from,
1617
to,
1718
// Return at most 10 candidates. We can make this configurable if needed.
18-
list: filtered(pairs, typed, 10).map(([seq, sym]) => ({
19-
text: sym,
20-
displayText: `${sym} \\${seq}`,
21-
hint: (cm: Editor) => cm.replaceRange(sym, from, to, "complete"),
22-
})),
19+
list: !typed
20+
? []
21+
: filtered(pairs, typed, 10).map(([seq, sym]) => ({
22+
text: sym,
23+
displayText: `${sym} \\${seq}`,
24+
hint: (cm: Editor) => cm.replaceRange(sym, from, to, "complete"),
25+
})),
2326
};
2427
};

0 commit comments

Comments
 (0)