Skip to content

Commit

Permalink
suggest: trigger when one starts typing before a word, e.g.,
Browse files Browse the repository at this point in the history
| - cursor

```typescript
const foo = new Foo()
|foo
```

typing in `c` when the current cursor is should trigger suggest, e.g., with suggestion `console`, etc.
  • Loading branch information
ulugbekna committed May 15, 2023
1 parent 29bf616 commit c7581b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/vs/editor/contrib/suggest/browser/suggestModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export class LineContext {
if (!word) {
return false;
}
if (word.endColumn !== pos.column) {
if (word.endColumn !== pos.column &&
word.startColumn + 1 !== pos.column /* after typing a single character before a word */) {
return false;
}
if (!isNaN(Number(word.word))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ suite('SuggestModel - Context', function () {

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

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

0 comments on commit c7581b5

Please sign in to comment.