From 3edb4eba1275412121b32d2186bcc5d9ac32dbe9 Mon Sep 17 00:00:00 2001 From: zitup Date: Wed, 5 Jun 2019 14:57:18 +0800 Subject: [PATCH] fix: ensure work only when type dot --- CHANGELOG.md | 8 ++++++++ README.md | 8 ++++---- package.json | 8 +++++--- src/completion.ts | 10 +++++++++- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3575527..40135cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,19 @@ # Change Log +## [0.0.3] - 2019-06-03 +### Fixed +- ensure work when only type dot +- remove duplicate elements from the proposal +- modify extension name from `className To Css` to `className Completion in CSS` + ## [0.0.2] - 2019-05-28 ### Added - support vue ## [0.0.1] - 2019-05-21 +### Init - support htm/html/jsx/tsx +[0.0.3]: https://github.com/zytjs/classNameToCss/releases/tag/0.0.3 [0.0.2]: https://github.com/zytjs/classNameToCss/releases/tag/0.0.2 [0.0.1]: https://github.com/zytjs/classNameToCss/releases/tag/0.0.1 \ No newline at end of file diff --git a/README.md b/README.md index 25f3ed7..3b5a119 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# IntelliSense for HTML class names in CSS +# IntelliSense for HTML classNames in CSS 在css/less/sass/stylus文件提供同一目录下,htm/html/jsx/tsx文件中className的智能提示。 在vue文件中,会提供本文件class的智能提示。 @@ -12,7 +12,7 @@ It will provide class name of **current** file if in `.vue` file. * 在css中提供className的自动补全提示 -* Gives you autocompletion in css for html class names in same directory or current file +* Gives you autocompletion in css for html class names in the same directory or current file # Supported File Extension @@ -30,6 +30,6 @@ It will provide class name of **current** file if in `.vue` file. This extension is very very easy to use, there just one step to improve your development efficiency: -* 搜索、安装、享受,然后与你的同事分享 +* 搜索、安装、输入点,然后与你的同事分享 -* Search, Install, Enjoy and Share with your colleague +* Search, Install, Type dot and Share with your colleague diff --git a/package.json b/package.json index 737052b..5dd4076 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "classnametocss", - "displayName": "className To Css", - "description": "css/less/scss intelliSense from html/jsx/tsx className", + "displayName": "className Completion in CSS", + "description": "css/less/scss className IntelliSense from html/jsx/tsx", "publisher": "zitup", - "version": "0.0.2", + "version": "0.0.3", "icon": "icon.jpg", "engines": { "vscode": "^1.33.0" @@ -16,6 +16,8 @@ "Other" ], "keywords": [ + "IntelliSense", + "completion", "autocomplete", "class", "css", diff --git a/src/completion.ts b/src/completion.ts index ffc9996..a974122 100644 --- a/src/completion.ts +++ b/src/completion.ts @@ -13,10 +13,16 @@ const sxMatchRegex: RegExp = /className="[\w-]+"/g; */ function provideCompletionItems( document: vscode.TextDocument, - _position: vscode.Position, + position: vscode.Position, _token: vscode.CancellationToken, _context: vscode.CompletionContext ) { + const typeText = document + .lineAt(position) + .text.substring(position.character - 1, position.character); + if (typeText !== ".") { + return; + } // 获取当前文件路径 const filePath: string = document.fileName; @@ -47,6 +53,8 @@ function provideCompletionItems( classNames = classNames.concat(result); } }); + // 去重 + classNames = [...new Set(classNames)]; } return classNames.map((item: string) => {