mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-04-17 01:49:41 -05:00
supressFormatOnKeyInComments
This commit is contained in:
@@ -31,6 +31,11 @@ namespace ts.formatting {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const indentationOfEnclosingMultiLineComment = getIndentationOfEnclosingMultiLineComment(sourceFile, position, options);
|
||||
if (indentationOfEnclosingMultiLineComment >= 0) {
|
||||
return indentationOfEnclosingMultiLineComment;
|
||||
}
|
||||
|
||||
const precedingToken = findPrecedingToken(position, sourceFile);
|
||||
if (!precedingToken) {
|
||||
return getBaseIndentation(options);
|
||||
@@ -44,11 +49,6 @@ namespace ts.formatting {
|
||||
|
||||
const lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
|
||||
const indentationOfEnclosingMultiLineComment = getIndentationOfEnclosingMultiLineComment(sourceFile, position, options);
|
||||
if (indentationOfEnclosingMultiLineComment >= 0) {
|
||||
return indentationOfEnclosingMultiLineComment;
|
||||
}
|
||||
|
||||
// indentation is first non-whitespace character in a previous line
|
||||
// for block indentation, we should look for a line which contains something that's not
|
||||
// whitespace.
|
||||
|
||||
@@ -1757,17 +1757,20 @@ namespace ts {
|
||||
function getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[] {
|
||||
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
||||
const settings = toEditorSettings(options);
|
||||
if (key === "{") {
|
||||
return formatting.formatOnOpeningCurly(position, sourceFile, getRuleProvider(settings), settings);
|
||||
}
|
||||
else if (key === "}") {
|
||||
return formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings);
|
||||
}
|
||||
else if (key === ";") {
|
||||
return formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings);
|
||||
}
|
||||
else if (key === "\n") {
|
||||
return formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings);
|
||||
|
||||
if (!isInComment(sourceFile, position)) {
|
||||
if (key === "{") {
|
||||
return formatting.formatOnOpeningCurly(position, sourceFile, getRuleProvider(settings), settings);
|
||||
}
|
||||
else if (key === "}") {
|
||||
return formatting.formatOnClosingCurly(position, sourceFile, getRuleProvider(settings), settings);
|
||||
}
|
||||
else if (key === ";") {
|
||||
return formatting.formatOnSemicolon(position, sourceFile, getRuleProvider(settings), settings);
|
||||
}
|
||||
else if (key === "\n") {
|
||||
return formatting.formatOnEnter(position, sourceFile, getRuleProvider(settings), settings);
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user