From 87c85668af80c2fad2d0bd528e646ce365ec1765 Mon Sep 17 00:00:00 2001 From: yangfan <18767120422@163.com> Date: Thu, 9 Jun 2022 11:02:57 +0800 Subject: [PATCH] Release 1.5.3 (#1023) * fix: cursors position (#1022) * fix: special object key in square brackets (#1021) * feat: update version --- extensions/style-helper/CHANGELOG.md | 4 ++++ extensions/style-helper/package.json | 2 +- .../style-helper/src/cssClassAutoCompete/index.ts | 2 +- extensions/style-helper/src/styleInfoViewer/index.ts | 10 +++++++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/extensions/style-helper/CHANGELOG.md b/extensions/style-helper/CHANGELOG.md index 234518bd9..de74f5b32 100644 --- a/extensions/style-helper/CHANGELOG.md +++ b/extensions/style-helper/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 1.1.1 +- feat: change cursors position when auto complete the css class name [#1019](https://github.com/apptools-lab/AppWorks/issues/1019) +- fix: use square brackets when class name has special key [#1020](https://github.com/apptools-lab/AppWorks/issues/1020) + ## 1.1.1 - chore: update taobao npm registry from `https://registry.npm.taobao.org` to `https://registry.npmmirror.com` diff --git a/extensions/style-helper/package.json b/extensions/style-helper/package.json index 82cd4acb9..cf2c98c65 100644 --- a/extensions/style-helper/package.json +++ b/extensions/style-helper/package.json @@ -3,7 +3,7 @@ "displayName": "React Style Helper", "description": "Easily write styles(CSS/LESS/SASS).", "publisher": "iceworks-team", - "version": "1.1.1", + "version": "1.1.2", "engines": { "vscode": "^1.41.0" }, diff --git a/extensions/style-helper/src/cssClassAutoCompete/index.ts b/extensions/style-helper/src/cssClassAutoCompete/index.ts index 57106296c..375f1106a 100644 --- a/extensions/style-helper/src/cssClassAutoCompete/index.ts +++ b/extensions/style-helper/src/cssClassAutoCompete/index.ts @@ -32,7 +32,7 @@ function provideCompletionItems(document: vscode.TextDocument, position: vscode. return unique(classNames).map((className) => { const completionItem = new vscode.CompletionItem(`.${className}`, vscode.CompletionItemKind.Text); completionItem.detail = 'AppWorks'; - completionItem.insertText = `.${className} {\n \n}`; + completionItem.insertText = new vscode.SnippetString(`.${className} {\n $1\n}`); completionItem.command = { command: 'style-helper.recordCompletionItemSelect', title: '' }; return completionItem; }); diff --git a/extensions/style-helper/src/styleInfoViewer/index.ts b/extensions/style-helper/src/styleInfoViewer/index.ts index 5ce9131c7..835677058 100644 --- a/extensions/style-helper/src/styleInfoViewer/index.ts +++ b/extensions/style-helper/src/styleInfoViewer/index.ts @@ -60,9 +60,17 @@ function provideCompletionItems(document: vscode.TextDocument, position: vscode. ) { return findStyleSelectors(directory, styleDependencies).map((selector: string) => { // Remove class selector `.`, When use styles.xxx. - const completionItem = new vscode.CompletionItem(selector.replace('.', ''), vscode.CompletionItemKind.Variable); + const item = selector.replace('.', ''); + const completionItem = new vscode.CompletionItem(item, vscode.CompletionItemKind.Variable); completionItem.detail = 'AppWorks'; completionItem.command = { command: 'style-helper.recordCompletionItemSelect', title: '' }; + // stlye.xxx-xxx to stlye['xxx-xxx'] + if (!/^[a-zA-Z]+$/.test(item)) { + completionItem.insertText = `['${item}']`; + completionItem.additionalTextEdits = [ + vscode.TextEdit.delete(new vscode.Range(position.line, position.character - 1, position.line, position.character)), + ]; + } return completionItem; }); }