From a00285712822d395c3d63f2c603ab24886729c3d Mon Sep 17 00:00:00 2001 From: "3207514785@qq.com" <3207514785@qq.com> Date: Thu, 12 Dec 2024 14:03:49 +0800 Subject: [PATCH] Fix the issue where document.getWordRangeAtPosition() returns incorrect positions due to changes in the document before the results from getStyles() are returned. --- package.json | 2 +- src/provider.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 31acfcd..6187837 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-html-css", "displayName": "HTML CSS Support", "description": "CSS Intellisense for HTML", - "version": "2.0.11", + "version": "2.0.12", "license": "MIT", "publisher": "ecmel", "author": { diff --git a/src/provider.ts b/src/provider.ts index d1e7812..00cd36b 100644 --- a/src/provider.ts +++ b/src/provider.ts @@ -129,8 +129,8 @@ export class Provider implements CompletionItemProvider, DefinitionProvider { position: Position, type: StyleType ) { - const map = await this.getCompletionMap(document, type); const range = document.getWordRangeAtPosition(position, this.wordRange); + const map = await this.getCompletionMap(document, type); const items = []; for (const item of map.values()) { @@ -164,8 +164,8 @@ export class Provider implements CompletionItemProvider, DefinitionProvider { } private async getDefinitions(document: TextDocument, position: Position) { - const styles = await this.getStyles(document); const range = document.getWordRangeAtPosition(position, this.wordRange); + const styles = await this.getStyles(document); const selector = document.getText(range); const locations: Location[] = [];