From 28b1b5a016787ec4119d28f057a9d93814d4e310 Mon Sep 17 00:00:00 2001 From: puelo Date: Wed, 10 May 2023 18:30:39 +0200 Subject: [PATCH] fix: script offset if vue-sfc contains template above (#3135) Co-authored-by: Rikki Schulte --- .changeset/thin-poems-search.md | 5 +++ .../src/__tests__/findGraphQLTags-test.ts | 38 +++++++++++++++++++ .../src/findGraphQLTags.ts | 16 ++++++-- 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 .changeset/thin-poems-search.md diff --git a/.changeset/thin-poems-search.md b/.changeset/thin-poems-search.md new file mode 100644 index 00000000000..23bac05937a --- /dev/null +++ b/.changeset/thin-poems-search.md @@ -0,0 +1,5 @@ +--- +'graphql-language-service-server': patch +--- + +fixed wrong script tag offset for vue-sfc diff --git a/packages/graphql-language-service-server/src/__tests__/findGraphQLTags-test.ts b/packages/graphql-language-service-server/src/__tests__/findGraphQLTags-test.ts index fbc9966f79e..cab838fae88 100644 --- a/packages/graphql-language-service-server/src/__tests__/findGraphQLTags-test.ts +++ b/packages/graphql-language-service-server/src/__tests__/findGraphQLTags-test.ts @@ -238,6 +238,25 @@ query {id} const contents = findGraphQLTags(text, '.vue'); expect(contents[0].template).toEqual(` query {id}`); + expect(contents[0].range.start.line).toEqual(2); + expect(contents[0].range.end.line).toEqual(4); + }); + + it('finds queries in tagged templates in Vue SFC using +`; + const contents = findGraphQLTags(text, '.vue'); + expect(contents[0].template).toEqual(` +query {id}`); + expect(contents[0].range.start.line).toEqual(4); + expect(contents[0].range.end.line).toEqual(6); }); it('finds queries in tagged templates in Vue SFC using normal +`; + const contents = findGraphQLTags(text, '.vue'); + expect(contents[0].template).toEqual(` +query {id}`); + expect(contents[0].range.start.line).toEqual(4); + expect(contents[0].range.end.line).toEqual(6); }); it('finds queries in tagged templates in Vue SFC using