1- import { CodeAction , CodeActionKind , Diagnostic , DiagnosticSeverity , DocumentDiagnosticReportKind , FullDocumentDiagnosticReport } from 'lsp-types' ;
1+ import { CodeAction , CodeActionKind , Diagnostic , DiagnosticSeverity , DocumentDiagnosticReportKind , FullDocumentDiagnosticReport , Range } from 'lsp-types' ;
22import { sysparser , syxparser } from './ast.js' ;
33import { tokenizeSys , tokenizeSyx } from './lexer.js' ;
44import { isCompilerError } from './types.js' ;
@@ -27,7 +27,7 @@ export function createSyntaxScriptDiagnosticReport(filePath: string, fileContent
2727 if ( isCompilerError ( error ) ) {
2828 items . push ( {
2929 message : error . message ,
30- range : error . range ,
30+ range : subRange ( error . range ) ,
3131 severity : DiagnosticSeverity . Error ,
3232 source : 'syntax-script' ,
3333 data : [
@@ -38,7 +38,7 @@ export function createSyntaxScriptDiagnosticReport(filePath: string, fileContent
3838 changes : {
3939 [ filePath ] : [
4040 {
41- range :error . range ,
41+ range :subRange ( error . range ) ,
4242 newText :'test'
4343 }
4444 ]
@@ -54,3 +54,13 @@ export function createSyntaxScriptDiagnosticReport(filePath: string, fileContent
5454 }
5555
5656}
57+
58+
59+ /**
60+ * Modifies the given range to be zero-based.
61+ * @param {Range } r Any range.
62+ * @returns Same range with every value decreased by 1.
63+ */
64+ function subRange ( r :Range ) :Range {
65+ return { start :{ character :r . start . character - 1 , line :r . start . line - 1 } , end :{ character :r . end . character - 1 , line :r . end . line - 1 } } ;
66+ }
0 commit comments