mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -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:
@@ -306,7 +306,7 @@ interface Array<T> {}`
|
||||
cancellationToken: { throwIfCancellationRequested: noop, isCancellationRequested: returnFalse },
|
||||
preferences: emptyOptions,
|
||||
host: notImplementedHost,
|
||||
formatContext: formatting.getFormatContext(testFormatSettings)
|
||||
formatContext: formatting.getFormatContext(testFormatSettings, notImplementedHost)
|
||||
};
|
||||
|
||||
const diagnostics = languageService.getSuggestionDiagnostics(f.path);
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace ts {
|
||||
startPosition: selectionRange.pos,
|
||||
endPosition: selectionRange.end,
|
||||
host: notImplementedHost,
|
||||
formatContext: formatting.getFormatContext(testFormatSettings),
|
||||
formatContext: formatting.getFormatContext(testFormatSettings, notImplementedHost),
|
||||
preferences: emptyOptions,
|
||||
};
|
||||
const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromRange(selectionRange));
|
||||
@@ -164,7 +164,7 @@ namespace ts {
|
||||
startPosition: selectionRange.pos,
|
||||
endPosition: selectionRange.end,
|
||||
host: notImplementedHost,
|
||||
formatContext: formatting.getFormatContext(testFormatSettings),
|
||||
formatContext: formatting.getFormatContext(testFormatSettings, notImplementedHost),
|
||||
preferences: emptyOptions,
|
||||
};
|
||||
const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromRange(selectionRange));
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace ts {
|
||||
const newLineCharacter = getNewLineCharacter(printerOptions);
|
||||
|
||||
function getRuleProvider(placeOpenBraceOnNewLineForFunctions: boolean): formatting.FormatContext {
|
||||
return formatting.getFormatContext(placeOpenBraceOnNewLineForFunctions ? { ...testFormatSettings, placeOpenBraceOnNewLineForFunctions: true } : testFormatSettings);
|
||||
return formatting.getFormatContext(placeOpenBraceOnNewLineForFunctions ? { ...testFormatSettings, placeOpenBraceOnNewLineForFunctions: true } : testFormatSettings, notImplementedHost);
|
||||
}
|
||||
|
||||
// validate that positions that were recovered from the printed text actually match positions that will be created if the same text is parsed.
|
||||
|
||||
Reference in New Issue
Block a user