Skip to content

Commit c7581b5

Browse files
committed
suggest: trigger when one starts typing before a word, e.g.,
| - cursor ```typescript const foo = new Foo() |foo ``` typing in `c` when the current cursor is should trigger suggest, e.g., with suggestion `console`, etc.
1 parent 29bf616 commit c7581b5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/vs/editor/contrib/suggest/browser/suggestModel.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ export class LineContext {
7272
if (!word) {
7373
return false;
7474
}
75-
if (word.endColumn !== pos.column) {
75+
if (word.endColumn !== pos.column &&
76+
word.startColumn + 1 !== pos.column /* after typing a single character before a word */) {
7677
return false;
7778
}
7879
if (!isNaN(Number(word.word))) {

src/vs/editor/contrib/suggest/test/browser/suggestModel.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ suite('SuggestModel - Context', function () {
142142

143143
assertAutoTrigger(model, 3, true, 'end of word, Das|');
144144
assertAutoTrigger(model, 4, false, 'no word Das |');
145-
assertAutoTrigger(model, 1, false, 'middle of word D|as');
145+
assertAutoTrigger(model, 1, true, 'typing a single character before a word: D|as');
146146
assertAutoTrigger(model, 55, false, 'number, 1861|');
147147
model.dispose();
148148
});
@@ -157,7 +157,7 @@ suite('SuggestModel - Context', function () {
157157

158158
assertAutoTrigger(model, 1, true, 'a|<x — should trigger at end of word');
159159
assertAutoTrigger(model, 2, false, 'a<|x — should NOT trigger at start of word');
160-
assertAutoTrigger(model, 3, false, 'a<x|x — should NOT trigger in middle of word');
160+
assertAutoTrigger(model, 3, true, 'a<x|x — should trigger after typing a single character before a word');
161161
assertAutoTrigger(model, 4, true, 'a<xx|> — should trigger at boundary between languages');
162162
assertAutoTrigger(model, 5, false, 'a<xx>|a — should NOT trigger at start of word');
163163
assertAutoTrigger(model, 6, true, 'a<xx>a|< — should trigger at end of word');

0 commit comments

Comments
 (0)