Skip to content

Commit 6182a99

Browse files
author
Loïc Mangeonjean
committed
fix: prevent throwing Uncaught error on cancel
1 parent b0bcc33 commit 6182a99

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/vs/workbench/contrib/output/common/outputChannelModel.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { VSBuffer } from 'vs/base/common/buffer';
2222
import { ILogger, ILoggerService, ILogService } from 'vs/platform/log/common/log';
2323
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
2424
import { OutputChannelUpdateMode } from 'vs/workbench/services/output/common/output';
25+
import { isCancellationError } from 'vs/base/common/errors';
2526

2627
export interface IOutputChannelModel extends IDisposable {
2728
readonly onDispose: Event<void>;
@@ -61,7 +62,11 @@ class OutputFileListener extends Disposable {
6162

6263
private poll(): void {
6364
const loop = () => this.doWatch().then(() => this.poll());
64-
this.syncDelayer.trigger(loop);
65+
this.syncDelayer.trigger(loop).catch(error => {
66+
if (!isCancellationError(error)) {
67+
throw error;
68+
}
69+
});
6570
}
6671

6772
private async doWatch(): Promise<void> {
@@ -206,7 +211,7 @@ export class FileOutputChannelModel extends Disposable implements IOutputChannel
206211
this.doUpdateModel(model, [EditOperation.delete(model.getFullModelRange())], VSBuffer.fromString(''));
207212
}
208213

209-
private async appendContent(model: ITextModel, immediate: boolean, token: CancellationToken): Promise<void> {
214+
private appendContent(model: ITextModel, immediate: boolean, token: CancellationToken): void {
210215
this.appendThrottler.trigger(async () => {
211216
/* Abort if operation is cancelled */
212217
if (token.isCancellationRequested) {
@@ -234,7 +239,11 @@ export class FileOutputChannelModel extends Disposable implements IOutputChannel
234239
const lastLineMaxColumn = model.getLineMaxColumn(lastLine);
235240
const edits = [EditOperation.insert(new Position(lastLine, lastLineMaxColumn), contentToAppend.toString())];
236241
this.doUpdateModel(model, edits, contentToAppend);
237-
}, immediate ? 0 : undefined);
242+
}, immediate ? 0 : undefined).catch(error => {
243+
if (!isCancellationError(error)) {
244+
throw error;
245+
}
246+
});
238247
}
239248

240249
private async replaceContent(model: ITextModel, token: CancellationToken): Promise<void> {

0 commit comments

Comments
 (0)