diff --git a/.changeset/cuddly-moons-decide.md b/.changeset/cuddly-moons-decide.md new file mode 100644 index 00000000..0a6b613c --- /dev/null +++ b/.changeset/cuddly-moons-decide.md @@ -0,0 +1,7 @@ +--- +"@astrojs/language-server": patch +"astro-vscode": patch +"@astrojs/check": patch +--- + +Fixes an issue where errors inside script and style tags could be offset by a few characters when multi bytes characters were present in the file diff --git a/packages/language-server/package.json b/packages/language-server/package.json index c3c20767..64d08e99 100644 --- a/packages/language-server/package.json +++ b/packages/language-server/package.json @@ -21,7 +21,7 @@ "test:match": "pnpm run test -g" }, "dependencies": { - "@astrojs/compiler": "^2.10.1", + "@astrojs/compiler": "^2.10.2", "@jridgewell/sourcemap-codec": "^1.4.15", "@volar/kit": "~2.4.0-alpha.15", "@volar/language-core": "~2.4.0-alpha.15", diff --git a/packages/language-server/test/typescript/scripts.test.ts b/packages/language-server/test/typescript/scripts.test.ts index 3969766a..94300517 100644 --- a/packages/language-server/test/typescript/scripts.test.ts +++ b/packages/language-server/test/typescript/scripts.test.ts @@ -1,4 +1,4 @@ -import { FullDocumentDiagnosticReport, Position } from '@volar/language-server'; +import { type FullDocumentDiagnosticReport, Position, Range } from '@volar/language-server'; import { expect } from 'chai'; import { type LanguageServer, getLanguageServer } from '../server.js'; @@ -59,4 +59,19 @@ describe('TypeScript - Diagnostics', async () => { expect(hoverInfo).to.be.null; }); + + it('supports script tags in files with multibytes characters', async () => { + const document = await languageServer.openFakeDocument( + `🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 +`, + 'astro' + ); + + const diagnostics = (await languageServer.handle.sendDocumentDiagnosticRequest( + document.uri + )) as FullDocumentDiagnosticReport; + + expect(diagnostics.items).length(1); + expect(diagnostics.items[0].range).to.deep.equal(Range.create(1, 8, 1, 20)); + }); }); diff --git a/packages/vscode/package.json b/packages/vscode/package.json index b565ef2b..3ab0165f 100644 --- a/packages/vscode/package.json +++ b/packages/vscode/package.json @@ -229,7 +229,7 @@ "vscode-tmgrammar-test": "^0.1.2" }, "dependencies": { - "@astrojs/compiler": "^2.10.1", + "@astrojs/compiler": "^2.10.2", "prettier": "^3.2.5", "prettier-plugin-astro": "^0.14.1" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a8045635..c8ee96f1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -76,8 +76,8 @@ importers: packages/language-server: dependencies: '@astrojs/compiler': - specifier: ^2.10.1 - version: 2.10.1 + specifier: ^2.10.2 + version: 2.10.2 '@jridgewell/sourcemap-codec': specifier: ^1.4.15 version: 1.4.15 @@ -222,8 +222,8 @@ importers: packages/vscode: dependencies: '@astrojs/compiler': - specifier: ^2.10.1 - version: 2.10.1 + specifier: ^2.10.2 + version: 2.10.2 prettier: specifier: ^3.2.5 version: 3.2.5 @@ -312,6 +312,9 @@ packages: /@astrojs/compiler@2.10.1: resolution: {integrity: sha512-XmM4j6BjvOVMag2xELq0JuG2yKOW8wgIu6dvb9BsjbGYmnvoStJn/pqEzVqc1EBszf2xYT7onIkftIOUz9AwrQ==} + /@astrojs/compiler@2.10.2: + resolution: {integrity: sha512-bvH+v8AirwpRWCkYJEyWYdc5Cs/BjG2ZTxIJzttHilXgfKJAdW2496KsUQKzf5j2tOHtaHXKKn9hb9WZiBGpEg==} + /@astrojs/internal-helpers@0.2.1: resolution: {integrity: sha512-06DD2ZnItMwUnH81LBLco3tWjcZ1lGU9rLCCBaeUCGYe9cI0wKyY2W3kDyoW1I6GmcWgt1fu+D1CTvz+FIKf8A==} dev: true @@ -2767,7 +2770,7 @@ packages: engines: {node: '>=18.14.1', npm: '>=6.14.0'} hasBin: true dependencies: - '@astrojs/compiler': 2.10.1 + '@astrojs/compiler': 2.10.2 '@astrojs/internal-helpers': 0.2.1 '@astrojs/markdown-remark': 4.2.1 '@astrojs/telemetry': 3.0.4 @@ -6175,7 +6178,7 @@ packages: resolution: {integrity: sha512-RiBETaaP9veVstE4vUwSIcdATj6dKmXljouXc/DDNwBSPTp8FRkLGDSGFClKsAFeeg+13SB0Z1JZvbD76bigJw==} engines: {node: ^14.15.0 || >=16.0.0} dependencies: - '@astrojs/compiler': 2.10.1 + '@astrojs/compiler': 2.10.2 prettier: 3.2.5 sass-formatter: 0.7.6 dev: false