File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,12 @@ namespace ts.formatting {
7272 }
7373 }
7474
75+ const containerList = getListByPosition ( position , precedingToken . parent ) ;
76+ // use list position if the preceding token is before any list items
77+ if ( containerList && ! rangeContainsRange ( containerList , precedingToken ) ) {
78+ return getActualIndentationForListStartLine ( containerList , sourceFile , options ) + options . indentSize ;
79+ }
80+
7581 // try to find node that can contribute to indentation and includes 'position' starting from 'precedingToken'
7682 // if such node is found - compute initial indentation for 'position' inside this node
7783 let previous : Node ;
@@ -342,6 +348,13 @@ namespace ts.formatting {
342348 }
343349 }
344350
351+ function getActualIndentationForListStartLine ( list : NodeArray < Node > , sourceFile : SourceFile , options : EditorSettings ) : number {
352+ if ( ! list ) {
353+ return Value . Unknown ;
354+ }
355+ return findColumnForFirstNonWhitespaceCharacterInLine ( sourceFile . getLineAndCharacterOfPosition ( list . pos ) , sourceFile , options ) ;
356+ }
357+
345358 function getActualIndentationForListItem ( node : Node , sourceFile : SourceFile , options : EditorSettings ) : number {
346359 const containingList = getContainingList ( node , sourceFile ) ;
347360 return containingList ? getActualIndentationFromList ( containingList ) : Value . Unknown ;
You can’t perform that action at this time.
0 commit comments