@@ -85,7 +85,7 @@ func getOwnOrInheritedDelta(n *ast.Node, options *FormatCodeSettings, sourceFile
8585 previousLine := - 1
8686 var child * ast.Node
8787 for n != nil {
88- line , _ := scanner .GetECMALineAndCharacterOfPosition (sourceFile , withTokenStart (n , sourceFile ).Pos ())
88+ line := scanner .GetECMALineOfPosition (sourceFile , withTokenStart (n , sourceFile ).Pos ())
8989 if previousLine != - 1 && line != previousLine {
9090 break
9191 }
@@ -242,10 +242,10 @@ func (w *formatSpanWorker) execute(s *formattingScanner) []core.TextChange {
242242 w .formattingScanner .advance ()
243243
244244 if w .formattingScanner .isOnToken () {
245- startLine , _ := scanner .GetECMALineAndCharacterOfPosition (w .sourceFile , withTokenStart (w .enclosingNode , w .sourceFile ).Pos ())
245+ startLine := scanner .GetECMALineOfPosition (w .sourceFile , withTokenStart (w .enclosingNode , w .sourceFile ).Pos ())
246246 undecoratedStartLine := startLine
247247 if ast .HasDecorators (w .enclosingNode ) {
248- undecoratedStartLine , _ = scanner .GetECMALineAndCharacterOfPosition (w .sourceFile , getNonDecoratorTokenPosOfNode (w .enclosingNode , w .sourceFile ))
248+ undecoratedStartLine = scanner .GetECMALineOfPosition (w .sourceFile , getNonDecoratorTokenPosOfNode (w .enclosingNode , w .sourceFile ))
249249 }
250250
251251 w .processNode (w .enclosingNode , w .enclosingNode , startLine , undecoratedStartLine , w .initialIndentation , w .delta )
@@ -305,7 +305,7 @@ func (w *formatSpanWorker) execute(s *formattingScanner) []core.TextChange {
305305 if parent == nil {
306306 parent = w .previousParent
307307 }
308- line , _ := scanner .GetECMALineAndCharacterOfPosition (w .sourceFile , tokenInfo .Loc .Pos ())
308+ line := scanner .GetECMALineOfPosition (w .sourceFile , tokenInfo .Loc .Pos ())
309309 w .processPair (
310310 tokenInfo ,
311311 line ,
@@ -343,11 +343,11 @@ func (w *formatSpanWorker) processChildNode(
343343 }
344344
345345 childStartPos := scanner .GetTokenPosOfNode (child , w .sourceFile , false )
346- childStartLine , _ := scanner .GetECMALineAndCharacterOfPosition (w .sourceFile , childStartPos )
346+ childStartLine := scanner .GetECMALineOfPosition (w .sourceFile , childStartPos )
347347
348348 undecoratedChildStartLine := childStartLine
349349 if ast .HasDecorators (child ) {
350- undecoratedChildStartLine , _ = scanner .GetECMALineAndCharacterOfPosition (w .sourceFile , getNonDecoratorTokenPosOfNode (child , w .sourceFile ))
350+ undecoratedChildStartLine = scanner .GetECMALineOfPosition (w .sourceFile , getNonDecoratorTokenPosOfNode (child , w .sourceFile ))
351351 }
352352
353353 // if child is a list item - try to get its indentation, only if parent is within the original range.
@@ -457,7 +457,7 @@ func (w *formatSpanWorker) processChildNodes(
457457 break
458458 } else if tokenInfo .token .Kind == listStartToken {
459459 // consume list start token
460- startLine , _ = scanner .GetECMALineAndCharacterOfPosition (w .sourceFile , tokenInfo .token .Loc .Pos ())
460+ startLine = scanner .GetECMALineOfPosition (w .sourceFile , tokenInfo .token .Loc .Pos ())
461461
462462 w .consumeTokenAndAdvanceScanner (tokenInfo , parent , parentDynamicIndentation , parent , false )
463463
@@ -578,7 +578,7 @@ func (w *formatSpanWorker) tryComputeIndentationForListItem(startPos int, endPos
578578 return inheritedIndentation
579579 }
580580 } else {
581- startLine , _ := scanner .GetECMALineAndCharacterOfPosition (w .sourceFile , startPos )
581+ startLine := scanner .GetECMALineOfPosition (w .sourceFile , startPos )
582582 startLinePosition := GetLineStartPositionForPosition (startPos , w .sourceFile )
583583 column := FindFirstNonWhitespaceColumn (startLinePosition , startPos , w .sourceFile , w .formattingContext .Options )
584584 if startLine != parentStartLine || startPos == column {
@@ -747,7 +747,7 @@ func (w *formatSpanWorker) processRange(r TextRangeWithKind, rangeStartLine int,
747747 if ! rangeHasError {
748748 if w .previousRange == NewTextRangeWithKind (0 , 0 , 0 ) {
749749 // trim whitespaces starting from the beginning of the span up to the current line
750- originalStartLine , _ := scanner .GetECMALineAndCharacterOfPosition (w .sourceFile , w .originalRange .Pos ())
750+ originalStartLine := scanner .GetECMALineOfPosition (w .sourceFile , w .originalRange .Pos ())
751751 w .trimTrailingWhitespacesForLines (originalStartLine , rangeStartLine , NewTextRangeWithKind (0 , 0 , 0 ))
752752 } else {
753753 lineAction = w .processPair (r , rangeStartLine , parent , w .previousRange , w .previousRangeStartLine , w .previousParent , contextNode , dynamicIndentation )
@@ -797,8 +797,8 @@ func (w *formatSpanWorker) trimTrailingWhitespacesForRemainingRange(trivias []Te
797797}
798798
799799func (w * formatSpanWorker ) trimTrailingWitespacesForPositions (startPos int , endPos int , previousRange TextRangeWithKind ) {
800- startLine , _ := scanner .GetECMALineAndCharacterOfPosition (w .sourceFile , startPos )
801- endLine , _ := scanner .GetECMALineAndCharacterOfPosition (w .sourceFile , endPos )
800+ startLine := scanner .GetECMALineOfPosition (w .sourceFile , startPos )
801+ endLine := scanner .GetECMALineOfPosition (w .sourceFile , endPos )
802802
803803 w .trimTrailingWhitespacesForLines (startLine , endLine + 1 , previousRange )
804804}
@@ -909,8 +909,8 @@ func (w *formatSpanWorker) indentTriviaItems(trivia []TextRangeWithKind, comment
909909
910910func (w * formatSpanWorker ) indentMultilineComment (commentRange core.TextRange , indentation int , firstLineIsIndented bool , indentFinalLine bool ) {
911911 // split comment in lines
912- startLine , _ := scanner .GetECMALineAndCharacterOfPosition (w .sourceFile , commentRange .Pos ())
913- endLine , _ := scanner .GetECMALineAndCharacterOfPosition (w .sourceFile , commentRange .End ())
912+ startLine := scanner .GetECMALineOfPosition (w .sourceFile , commentRange .Pos ())
913+ endLine := scanner .GetECMALineOfPosition (w .sourceFile , commentRange .End ())
914914
915915 if startLine == endLine {
916916 if ! firstLineIsIndented {
@@ -1033,7 +1033,7 @@ func (w *formatSpanWorker) consumeTokenAndAdvanceScanner(currentTokenInfo tokenI
10331033 if lineAction == LineActionNone {
10341034 // indent token only if end line of previous range does not match start line of the token
10351035 if savePreviousRange != NewTextRangeWithKind (0 , 0 , 0 ) {
1036- prevEndLine , _ := scanner .GetECMALineAndCharacterOfPosition (w .sourceFile , savePreviousRange .Loc .End ())
1036+ prevEndLine := scanner .GetECMALineOfPosition (w .sourceFile , savePreviousRange .Loc .End ())
10371037 indentToken = lastTriviaWasNewLine && tokenStartLine != prevEndLine
10381038 }
10391039 } else {
0 commit comments