From 8dc541fb065c5e4167ef6a3ba99ae41269c7051c Mon Sep 17 00:00:00 2001 From: jens1o Date: Tue, 1 Aug 2017 20:35:09 +0200 Subject: [PATCH] fix handling in stylesheets --- src/emmetHelper.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/emmetHelper.ts b/src/emmetHelper.ts index f93da2e..7e7c7ac 100644 --- a/src/emmetHelper.ts +++ b/src/emmetHelper.ts @@ -80,14 +80,16 @@ export function doComplete(document: TextDocument, position: Position, syntax: s expandedAbbr.label = abbreviation + filterDelimitor + bemFilterSuffix; } if (isStyleSheet(syntax)) { + let expandedTextWithoutTabStops = removeTabStops(expandedText); + // See https://github.com/Microsoft/vscode/issues/28933#issuecomment-309236902 // Due to this we set filterText, sortText and label to expanded abbreviation - // - Label makes it clear to the user what their choice is + // - Label makes it clear to the user what their choice is // - FilterText fixes the issue when user types in propertyname and emmet uses it to match with abbreviations // - SortText will sort the choice in a way that is intutive to the user - expandedAbbr.filterText = expandedAbbr.documentation; - expandedAbbr.sortText = expandedAbbr.documentation; - expandedAbbr.label = expandedAbbr.documentation; + expandedAbbr.filterText = expandedTextWithoutTabStops; + expandedAbbr.sortText = expandedTextWithoutTabStops; + expandedAbbr.label = expandedTextWithoutTabStops; return CompletionList.create([expandedAbbr], true); } } @@ -170,7 +172,11 @@ function getCurrentWord(document: TextDocument, position: Position): string { } function makeCursorsGorgeous(expandedWord: string): string { - return expandedWord.replace(/\$\{\d+\}/g, '|').replace(/\$\{\d+:([^\}]+)\}/g, '_$1_') + '|'; + return expandedWord.replace(/\$\{\d+\}/g, '|').replace(/\$\{\d+:([^\}]+)\}/g, '_$1_'); +} + +function removeTabStops(expandedWord: string): string { + return expandedWord.replace(/\$\{\d+\}/g, '').replace(/\$\{\d+:([^\}]+)\}/g, '$1'); } function getCurrentLine(document: TextDocument, position: Position): string {