mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-21 04:17:02 -06:00
indent using list start position before first list item
This commit is contained in:
parent
cd19a8910d
commit
655bf203d0
@ -66,6 +66,12 @@ namespace ts.formatting {
|
||||
}
|
||||
}
|
||||
|
||||
const containerList = getListByPosition(position, precedingToken.parent);
|
||||
// use list position if the preceding token is before any list items
|
||||
if (containerList && !rangeContainsRange(containerList, precedingToken)) {
|
||||
return getActualIndentationForListStartLine(containerList, sourceFile, options) + options.indentSize;
|
||||
}
|
||||
|
||||
return getSmartIndent(sourceFile, position, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options);
|
||||
}
|
||||
|
||||
@ -394,6 +400,13 @@ namespace ts.formatting {
|
||||
}
|
||||
}
|
||||
|
||||
function getActualIndentationForListStartLine(list: NodeArray<Node>, sourceFile: SourceFile, options: EditorSettings): number {
|
||||
if (!list) {
|
||||
return Value.Unknown;
|
||||
}
|
||||
return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options);
|
||||
}
|
||||
|
||||
function getActualIndentationForListItem(node: Node, sourceFile: SourceFile, options: EditorSettings): number {
|
||||
const containingList = getContainingList(node, sourceFile);
|
||||
if (containingList) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user