diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c022d4a95b9..d8b7c358a55 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1481,20 +1481,7 @@ module FourSlash { } public copyFormatOptions(): ts.FormatCodeOptions { - return { - ConvertTabsToSpaces: this.formatCodeOptions.ConvertTabsToSpaces, - IndentSize: this.formatCodeOptions.IndentSize, - InsertSpaceAfterCommaDelimiter: this.formatCodeOptions.InsertSpaceAfterCommaDelimiter, - InsertSpaceAfterFunctionKeywordForAnonymousFunctions: this.formatCodeOptions.InsertSpaceAfterFunctionKeywordForAnonymousFunctions, - InsertSpaceAfterKeywordsInControlFlowStatements: this.formatCodeOptions.InsertSpaceAfterKeywordsInControlFlowStatements, - InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: this.formatCodeOptions.InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis, - InsertSpaceAfterSemicolonInForStatements: this.formatCodeOptions.InsertSpaceAfterSemicolonInForStatements, - InsertSpaceBeforeAndAfterBinaryOperators: this.formatCodeOptions.InsertSpaceBeforeAndAfterBinaryOperators, - NewLineCharacter: this.formatCodeOptions.NewLineCharacter, - PlaceOpenBraceOnNewLineForControlBlocks: this.formatCodeOptions.PlaceOpenBraceOnNewLineForControlBlocks, - PlaceOpenBraceOnNewLineForFunctions: this.formatCodeOptions.PlaceOpenBraceOnNewLineForFunctions, - TabSize: this.formatCodeOptions.TabSize - } + return ts.clone(this.formatCodeOptions); } public setFormatOptions(formatCodeOptions: ts.FormatCodeOptions): ts.FormatCodeOptions { diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 89bf9e674ee..593e6163e29 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -306,6 +306,13 @@ module ts.formatting { return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options); } + /* + Character is the actual index of the character since the beginning of the line. + Column - position of the character after expanding tabs to spaces + "0\t2$" + value of 'character' for '$' is 3 + value of 'column' for '$' is 6 (assuming that tab size is 4) + */ export function findFirstNonWhitespaceCharacterAndColumn(startPos: number, endPos: number, sourceFile: SourceFile, options: EditorOptions) { var character = 0; var column = 0;