Ensure getNewLineFromContext never returns undefined

This commit is contained in:
Andrew Casey 2018-01-17 15:37:05 -08:00
parent 3ca1cc406a
commit 13bf7f9c7c

View file

@ -21,7 +21,7 @@ namespace ts {
export function getNewLineFromContext(context: RefactorOrCodeFixContext) {
const formatSettings = context.formatContext.options;
return formatSettings ? formatSettings.newLineCharacter : context.host.getNewLine();
return (formatSettings && formatSettings.newLineCharacter) || getNewLineOrDefaultFromHost(context.host);
}
export function toTextChangesContext(context: RefactorOrCodeFixContext): textChanges.TextChangesContext {