From 6be29042ac7df11e7336d46c13f0ec431c42974d Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 13 Nov 2025 16:46:41 -0800 Subject: [PATCH] Use SkipTrivia instead of GetRangeOfTokenAtPosition where possible --- internal/checker/checker.go | 2 +- internal/ls/lsutil/utilities.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 69a4f7c7f7..db09e26db0 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -3968,7 +3968,7 @@ func (c *Checker) checkWithStatement(node *ast.Node) { c.checkExpression(node.Expression()) sourceFile := ast.GetSourceFileOfNode(node) if !c.hasParseDiagnostics(sourceFile) { - start := scanner.GetRangeOfTokenAtPosition(sourceFile, node.Pos()).Pos() + start := scanner.SkipTrivia(sourceFile.Text(), node.Pos()) end := node.Statement().Pos() c.grammarErrorAtPos(sourceFile.AsNode(), start, end-start, diagnostics.The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any) } diff --git a/internal/ls/lsutil/utilities.go b/internal/ls/lsutil/utilities.go index 9e70cb915a..b5c6972bcc 100644 --- a/internal/ls/lsutil/utilities.go +++ b/internal/ls/lsutil/utilities.go @@ -37,7 +37,7 @@ func ProbablyUsesSemicolons(file *ast.SourceFile) bool { astnav.GetStartOfNode(lastToken, file, false /*includeJSDoc*/)) nextTokenLine := scanner.GetECMALineOfPosition( file, - scanner.GetRangeOfTokenAtPosition(file, lastToken.End()).Pos()) + scanner.SkipTrivia(file.Text(), lastToken.End())) // Avoid counting missing semicolon in single-line objects: // `function f(p: { x: string /*no semicolon here is insignificant*/ }) {` if lastTokenLine != nextTokenLine {