Skip to content

Commit 9739b76

Browse files
authored
Do not show the dialog if the dialog is currently being shown (microsoft#164441)
Fixes microsoft#148454: Do not show the dialog if the dialog is currently being shown
1 parent 6399d03 commit 9739b76

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/vs/editor/contrib/unusualLineTerminators/browser/unusualLineTerminators.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { EditorOption } from 'vs/editor/common/config/editorOptions';
1212
import { IEditorContribution } from 'vs/editor/common/editorCommon';
1313
import { ITextModel } from 'vs/editor/common/model';
1414
import * as nls from 'vs/nls';
15-
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
15+
import { IConfirmationResult, IDialogService } from 'vs/platform/dialogs/common/dialogs';
1616

1717
const ignoreUnusualLineTerminators = 'ignoreUnusualLineTerminators';
1818

@@ -29,6 +29,7 @@ export class UnusualLineTerminatorsDetector extends Disposable implements IEdito
2929
public static readonly ID = 'editor.contrib.unusualLineTerminatorsDetector';
3030

3131
private _config: 'auto' | 'off' | 'prompt';
32+
private _isPresentingDialog: boolean = false;
3233

3334
constructor(
3435
private readonly _editor: ICodeEditor,
@@ -85,13 +86,25 @@ export class UnusualLineTerminatorsDetector extends Disposable implements IEdito
8586
return;
8687
}
8788

88-
const result = await this._dialogService.confirm({
89-
title: nls.localize('unusualLineTerminators.title', "Unusual Line Terminators"),
90-
message: nls.localize('unusualLineTerminators.message', "Detected unusual line terminators"),
91-
detail: nls.localize('unusualLineTerminators.detail', "The file '{0}' contains one or more unusual line terminator characters, like Line Separator (LS) or Paragraph Separator (PS).\n\nIt is recommended to remove them from the file. This can be configured via `editor.unusualLineTerminators`.", basename(model.uri)),
92-
primaryButton: nls.localize('unusualLineTerminators.fix', "Remove Unusual Line Terminators"),
93-
secondaryButton: nls.localize('unusualLineTerminators.ignore', "Ignore")
94-
});
89+
if (this._isPresentingDialog) {
90+
// we're currently showing the dialog, which is async.
91+
// avoid spamming the user
92+
return;
93+
}
94+
95+
let result: IConfirmationResult;
96+
try {
97+
this._isPresentingDialog = true;
98+
result = await this._dialogService.confirm({
99+
title: nls.localize('unusualLineTerminators.title', "Unusual Line Terminators"),
100+
message: nls.localize('unusualLineTerminators.message', "Detected unusual line terminators"),
101+
detail: nls.localize('unusualLineTerminators.detail', "The file '{0}' contains one or more unusual line terminator characters, like Line Separator (LS) or Paragraph Separator (PS).\n\nIt is recommended to remove them from the file. This can be configured via `editor.unusualLineTerminators`.", basename(model.uri)),
102+
primaryButton: nls.localize('unusualLineTerminators.fix', "Remove Unusual Line Terminators"),
103+
secondaryButton: nls.localize('unusualLineTerminators.ignore', "Ignore")
104+
});
105+
} finally {
106+
this._isPresentingDialog = false;
107+
}
95108

96109
if (!result.confirmed) {
97110
// this model should be ignored

0 commit comments

Comments
 (0)