From e8a66223fe033d2466804bfafde0f00e2a6eb7a1 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 14 Feb 2023 21:15:07 +0100 Subject: [PATCH] HTML files default to save as .txt, but only if line 1 is not blank (fix #174048) (#174395) --- .../textfile/browser/textFileService.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/services/textfile/browser/textFileService.ts b/src/vs/workbench/services/textfile/browser/textFileService.ts index 88f8842da6fdc..a78fc891cf9c1 100644 --- a/src/vs/workbench/services/textfile/browser/textFileService.ts +++ b/src/vs/workbench/services/textfile/browser/textFileService.ts @@ -591,13 +591,18 @@ export abstract class AbstractTextFileService extends Disposable implements ITex // of untitled model if it is a valid path name and // figure out the file extension from the mode if any. + let nameCandidate: string; if (await this.pathService.hasValidBasename(joinPath(defaultFilePath, model.name), model.name)) { - const languageId = model.getLanguageId(); - if (languageId && languageId !== PLAINTEXT_LANGUAGE_ID) { - suggestedFilename = this.suggestFilename(languageId, model.name); - } else { - suggestedFilename = model.name; - } + nameCandidate = model.name; + } else { + nameCandidate = basename(resource); + } + + const languageId = model.getLanguageId(); + if (languageId && languageId !== PLAINTEXT_LANGUAGE_ID) { + suggestedFilename = this.suggestFilename(languageId, nameCandidate); + } else { + suggestedFilename = nameCandidate; } } }