Skip to content

Commit

Permalink
fix: ensure work only when type dot
Browse files Browse the repository at this point in the history
  • Loading branch information
zitup committed Jun 5, 2019
1 parent ac99493 commit 3edb4eb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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的智能提示。
Expand All @@ -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

Expand All @@ -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
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -16,6 +16,8 @@
"Other"
],
"keywords": [
"IntelliSense",
"completion",
"autocomplete",
"class",
"css",
Expand Down
10 changes: 9 additions & 1 deletion src/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -47,6 +53,8 @@ function provideCompletionItems(
classNames = classNames.concat(result);
}
});
// 去重
classNames = [...new Set(classNames)];
}

return classNames.map((item: string) => {
Expand Down

0 comments on commit 3edb4eb

Please sign in to comment.