From bbf88245aa5f1a8ec5ce4ea28342cbb69a8bd8a9 Mon Sep 17 00:00:00 2001 From: Li Xueli Date: Tue, 6 Oct 2020 14:20:15 +0800 Subject: [PATCH] Remove extra whitespace in the untitled editor label --- .../services/untitled/common/untitledTextEditorModel.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/services/untitled/common/untitledTextEditorModel.ts b/src/vs/workbench/services/untitled/common/untitledTextEditorModel.ts index b5ea40db3c90f..c06d942139abb 100644 --- a/src/vs/workbench/services/untitled/common/untitledTextEditorModel.ts +++ b/src/vs/workbench/services/untitled/common/untitledTextEditorModel.ts @@ -356,10 +356,11 @@ export class UntitledTextEditorModel extends BaseTextEditorModel implements IUnt // - cannot be only whitespace (so we trim()) // - cannot be only non-alphanumeric characters (so we run word definition regex over it) // - cannot be longer than FIRST_LINE_MAX_TITLE_LENGTH + // - normalize multiple whitespaces to a single whitespace let modelFirstWordsCandidate: string | undefined = undefined; - const firstLineText = this.textEditorModel?.getValueInRange({ startLineNumber: 1, endLineNumber: 1, startColumn: 1, endColumn: UntitledTextEditorModel.FIRST_LINE_NAME_MAX_LENGTH + 1 }).trim(); + const firstLineText = this.textEditorModel?.getValueInRange({ startLineNumber: 1, endLineNumber: 1, startColumn: 1, endColumn: UntitledTextEditorModel.FIRST_LINE_NAME_MAX_LENGTH + 1 }).trim().replace(/\s+/g, ' '); if (firstLineText && ensureValidWordDefinition().exec(firstLineText)) { modelFirstWordsCandidate = firstLineText; }