mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Ensure formatter can always get a newline character (#38579)
* Ensure formatter can always get a newline character * Make FormatContext.host optional since it’s not necessary if format options are all applied * Make FormattingHost required again
This commit is contained in:
@@ -515,6 +515,12 @@ namespace FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
public verifyOrganizeImports(newContent: string) {
|
||||
const changes = this.languageService.organizeImports({ fileName: this.activeFile.fileName, type: "file" }, this.formatCodeSettings, ts.emptyOptions);
|
||||
this.applyChanges(changes);
|
||||
this.verifyFileContent(this.activeFile.fileName, newContent);
|
||||
}
|
||||
|
||||
private raiseError(message: string): never {
|
||||
throw new Error(this.messageAtLastKnownMarker(message));
|
||||
}
|
||||
|
||||
@@ -560,6 +560,10 @@ namespace FourSlashInterface {
|
||||
public noMoveToNewFile(): void {
|
||||
this.state.noMoveToNewFile();
|
||||
}
|
||||
|
||||
public organizeImports(newContent: string) {
|
||||
this.state.verifyOrganizeImports(newContent);
|
||||
}
|
||||
}
|
||||
|
||||
export class Edit {
|
||||
|
||||
Reference in New Issue
Block a user