diff options
Diffstat (limited to 'subprojects/frontend/src/xtext/UpdateService.ts')
-rw-r--r-- | subprojects/frontend/src/xtext/UpdateService.ts | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/subprojects/frontend/src/xtext/UpdateService.ts b/subprojects/frontend/src/xtext/UpdateService.ts index d8782d90..f1abce52 100644 --- a/subprojects/frontend/src/xtext/UpdateService.ts +++ b/subprojects/frontend/src/xtext/UpdateService.ts | |||
@@ -1,9 +1,10 @@ | |||
1 | import type { ChangeDesc, Transaction } from '@codemirror/state'; | 1 | import type { ChangeDesc, Transaction } from '@codemirror/state'; |
2 | import { E_CANCELED, E_TIMEOUT } from 'async-mutex'; | ||
3 | import { debounce } from 'lodash-es'; | 2 | import { debounce } from 'lodash-es'; |
4 | import { nanoid } from 'nanoid'; | 3 | import { nanoid } from 'nanoid'; |
5 | 4 | ||
6 | import type EditorStore from '../editor/EditorStore'; | 5 | import type EditorStore from '../editor/EditorStore'; |
6 | import CancelledError from '../utils/CancelledError'; | ||
7 | import TimeoutError from '../utils/TimeoutError'; | ||
7 | import getLogger from '../utils/getLogger'; | 8 | import getLogger from '../utils/getLogger'; |
8 | 9 | ||
9 | import UpdateStateTracker from './UpdateStateTracker'; | 10 | import UpdateStateTracker from './UpdateStateTracker'; |
@@ -66,7 +67,7 @@ export default class UpdateService { | |||
66 | this.updateFullTextOrThrow().catch((error) => { | 67 | this.updateFullTextOrThrow().catch((error) => { |
67 | // Let E_TIMEOUT errors propagate, since if the first update times out, | 68 | // Let E_TIMEOUT errors propagate, since if the first update times out, |
68 | // we can't use the connection. | 69 | // we can't use the connection. |
69 | if (error === E_CANCELED) { | 70 | if (error instanceof CancelledError) { |
70 | // Content assist will perform a full-text update anyways. | 71 | // Content assist will perform a full-text update anyways. |
71 | log.debug('Full text update cancelled'); | 72 | log.debug('Full text update cancelled'); |
72 | return; | 73 | return; |
@@ -87,7 +88,7 @@ export default class UpdateService { | |||
87 | } | 88 | } |
88 | if (!this.tracker.lockedForUpdate) { | 89 | if (!this.tracker.lockedForUpdate) { |
89 | this.updateOrThrow().catch((error) => { | 90 | this.updateOrThrow().catch((error) => { |
90 | if (error === E_CANCELED || error === E_TIMEOUT) { | 91 | if (error instanceof CancelledError || error instanceof TimeoutError) { |
91 | log.debug('Idle update cancelled'); | 92 | log.debug('Idle update cancelled'); |
92 | return; | 93 | return; |
93 | } | 94 | } |
@@ -163,11 +164,15 @@ export default class UpdateService { | |||
163 | return this.fetchContentAssistFetchOnly(params, this.xtextStateId); | 164 | return this.fetchContentAssistFetchOnly(params, this.xtextStateId); |
164 | } | 165 | } |
165 | try { | 166 | try { |
166 | return await this.tracker.runExclusiveHighPriority(() => | 167 | return await this.tracker.runExclusive( |
167 | this.fetchContentAssistExclusive(params, signal), | 168 | () => this.fetchContentAssistExclusive(params, signal), |
169 | true, | ||
168 | ); | 170 | ); |
169 | } catch (error) { | 171 | } catch (error) { |
170 | if ((error === E_CANCELED || error === E_TIMEOUT) && signal.aborted) { | 172 | if ( |
173 | (error instanceof CancelledError || error instanceof TimeoutError) && | ||
174 | signal.aborted | ||
175 | ) { | ||
171 | return []; | 176 | return []; |
172 | } | 177 | } |
173 | throw error; | 178 | throw error; |
@@ -261,9 +266,7 @@ export default class UpdateService { | |||
261 | } | 266 | } |
262 | 267 | ||
263 | formatText(): Promise<void> { | 268 | formatText(): Promise<void> { |
264 | return this.tracker.runExclusiveWithRetries(() => | 269 | return this.tracker.runExclusive(() => this.formatTextExclusive()); |
265 | this.formatTextExclusive(), | ||
266 | ); | ||
267 | } | 270 | } |
268 | 271 | ||
269 | private async formatTextExclusive(): Promise<void> { | 272 | private async formatTextExclusive(): Promise<void> { |
@@ -294,7 +297,7 @@ export default class UpdateService { | |||
294 | try { | 297 | try { |
295 | await this.updateOrThrow(); | 298 | await this.updateOrThrow(); |
296 | } catch (error) { | 299 | } catch (error) { |
297 | if (error === E_CANCELED || error === E_TIMEOUT) { | 300 | if (error instanceof CancelledError || error instanceof TimeoutError) { |
298 | return { cancelled: true }; | 301 | return { cancelled: true }; |
299 | } | 302 | } |
300 | throw error; | 303 | throw error; |