Mirror: TypeScript LSP plugin that finds GraphQL documents in your code and provides diagnostics, auto-complete and hover-information.

fix out of bounds index (#207)

Changed files
+7 -2
.changeset
packages
graphqlsp
+5
.changeset/big-masks-remain.md
···
+
---
+
'@0no-co/graphqlsp': patch
+
---
+
+
Fix case for call-expression where index would go out of bounds due to fragments being external to the document. In tagged-templates we resolve this by adding it in to the original text
+2 -2
packages/graphqlsp/src/diagnostics.ts
···
let startChar = startingPosition + start.line;
for (let i = 0; i <= start.line; i++) {
if (i === start.line) startChar += start.character;
-
else startChar += lines[i].length;
+
else if (lines[i]) startChar += lines[i].length;
}
let endChar = startingPosition + end.line;
for (let i = 0; i <= end.line; i++) {
if (i === end.line) endChar += end.character;
-
else endChar += lines[i].length;
+
else if (lines[i]) endChar += lines[i].length;
}
const locatedInFragment = resolvedSpans.find(x => {