diff options
Diffstat (limited to 'language-web/src/main/js/xtext/ContentAssistService.ts')
-rw-r--r-- | language-web/src/main/js/xtext/ContentAssistService.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/language-web/src/main/js/xtext/ContentAssistService.ts b/language-web/src/main/js/xtext/ContentAssistService.ts index 9cbb385f..ec6b80d2 100644 --- a/language-web/src/main/js/xtext/ContentAssistService.ts +++ b/language-web/src/main/js/xtext/ContentAssistService.ts | |||
@@ -3,7 +3,7 @@ import type { | |||
3 | CompletionContext, | 3 | CompletionContext, |
4 | CompletionResult, | 4 | CompletionResult, |
5 | } from '@codemirror/autocomplete'; | 5 | } from '@codemirror/autocomplete'; |
6 | import type { ChangeSet, Transaction } from '@codemirror/state'; | 6 | import type { Transaction } from '@codemirror/state'; |
7 | import escapeStringRegexp from 'escape-string-regexp'; | 7 | import escapeStringRegexp from 'escape-string-regexp'; |
8 | 8 | ||
9 | import type { UpdateService } from './UpdateService'; | 9 | import type { UpdateService } from './UpdateService'; |
@@ -62,7 +62,7 @@ export class ContentAssistService { | |||
62 | } | 62 | } |
63 | 63 | ||
64 | onTransaction(transaction: Transaction): void { | 64 | onTransaction(transaction: Transaction): void { |
65 | if (this.shouldInvalidateCachedCompletion(transaction.changes)) { | 65 | if (this.shouldInvalidateCachedCompletion(transaction)) { |
66 | this.lastCompletion = null; | 66 | this.lastCompletion = null; |
67 | } | 67 | } |
68 | } | 68 | } |
@@ -142,8 +142,8 @@ export class ContentAssistService { | |||
142 | return from >= transformedFrom && to <= transformedTo && span && span.exec(text); | 142 | return from >= transformedFrom && to <= transformedTo && span && span.exec(text); |
143 | } | 143 | } |
144 | 144 | ||
145 | private shouldInvalidateCachedCompletion(changes: ChangeSet) { | 145 | private shouldInvalidateCachedCompletion(transaction: Transaction) { |
146 | if (changes.empty || this.lastCompletion === null) { | 146 | if (!transaction.docChanged || this.lastCompletion === null) { |
147 | return false; | 147 | return false; |
148 | } | 148 | } |
149 | const { from: lastFrom, to: lastTo } = this.lastCompletion; | 149 | const { from: lastFrom, to: lastTo } = this.lastCompletion; |
@@ -152,7 +152,7 @@ export class ContentAssistService { | |||
152 | } | 152 | } |
153 | const [transformedFrom, transformedTo] = this.mapRangeInclusive(lastFrom, lastTo); | 153 | const [transformedFrom, transformedTo] = this.mapRangeInclusive(lastFrom, lastTo); |
154 | let invalidate = false; | 154 | let invalidate = false; |
155 | changes.iterChangedRanges((fromA, toA) => { | 155 | transaction.changes.iterChangedRanges((fromA, toA) => { |
156 | if (fromA < transformedFrom || toA > transformedTo) { | 156 | if (fromA < transformedFrom || toA > transformedTo) { |
157 | invalidate = true; | 157 | invalidate = true; |
158 | } | 158 | } |