Skip to content

Commit c1d6f46

Browse files
authored
fix wrong offsets by altering the source-file after doing original diag (#53)
1 parent b123c4f commit c1d6f46

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

.changeset/shaggy-ravens-train.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@0no-co/graphqlsp': patch
3+
---
4+
5+
First perform the graphqlsp operations and only after do the TypeScript ones, this to account for changed lines from semantic-diagnostics

packages/graphqlsp/src/index.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,16 @@ function create(info: ts.server.PluginCreateInfo) {
4646
);
4747

4848
proxy.getSemanticDiagnostics = (filename: string): ts.Diagnostic[] => {
49-
const originalDiagnostics =
50-
info.languageService.getSemanticDiagnostics(filename);
5149
const graphQLDiagnostics = getGraphQLDiagnostics(
5250
filename,
5351
baseTypesPath,
5452
schema,
5553
info
5654
);
55+
56+
const originalDiagnostics =
57+
info.languageService.getSemanticDiagnostics(filename);
58+
5759
return graphQLDiagnostics
5860
? [...graphQLDiagnostics, ...originalDiagnostics]
5961
: originalDiagnostics;
@@ -64,6 +66,13 @@ function create(info: ts.server.PluginCreateInfo) {
6466
cursorPosition: number,
6567
options: any
6668
): ts.WithMetadata<ts.CompletionInfo> | undefined => {
69+
const completions = getGraphQLCompletions(
70+
filename,
71+
cursorPosition,
72+
schema,
73+
info
74+
);
75+
6776
const originalCompletions = info.languageService.getCompletionsAtPosition(
6877
filename,
6978
cursorPosition,
@@ -75,13 +84,6 @@ function create(info: ts.server.PluginCreateInfo) {
7584
entries: [],
7685
};
7786

78-
const completions = getGraphQLCompletions(
79-
filename,
80-
cursorPosition,
81-
schema,
82-
info
83-
);
84-
8587
if (completions) {
8688
return {
8789
...completions,
@@ -93,18 +95,18 @@ function create(info: ts.server.PluginCreateInfo) {
9395
};
9496

9597
proxy.getQuickInfoAtPosition = (filename: string, cursorPosition: number) => {
96-
const originalInfo = info.languageService.getQuickInfoAtPosition(
97-
filename,
98-
cursorPosition
99-
);
100-
10198
const quickInfo = getGraphQLQuickInfo(
10299
filename,
103100
cursorPosition,
104101
schema,
105102
info
106103
);
107104

105+
const originalInfo = info.languageService.getQuickInfoAtPosition(
106+
filename,
107+
cursorPosition
108+
);
109+
108110
return quickInfo || originalInfo;
109111
};
110112

0 commit comments

Comments
 (0)