Skip to content

Commit

Permalink
HTML files default to save as .txt, but only if line 1 is not blank (fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero authored Feb 14, 2023
1 parent 9127d2f commit e8a6622
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/vs/workbench/services/textfile/browser/textFileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit e8a6622

Please sign in to comment.