Skip to content

Commit

Permalink
fix: includes , log or else error
Browse files Browse the repository at this point in the history
  • Loading branch information
vtrbo committed Jul 15, 2022
1 parent b160b4f commit a11bc49
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
},
"devDependencies": {
"@babel/types": "^7.18.8",
"@types/node": "^18.0.3",
"@types/node": "^18.0.4",
"@types/vscode": "^1.69.0",
"@vtrbo/eslint-config": "^0.0.3",
"bumpp": "^8.2.1",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as vscode from 'vscode'
import type { IOption } from './types'
import { matchRealType } from './utils'
import { compute$Label, matchRealType } from './utils'
import { CompletionItemProvider } from './provider'
import { defaultLanguages, defaultOptions } from './constant'

Expand Down Expand Up @@ -40,7 +40,7 @@ export function activate(context: vscode.ExtensionContext): void {
} = {
$simple: matchRealType(content).substring(0, 3),
$stamp: matchRealType(content),
$label: `'${content.replace(/^\'(.*?)\'$/g, '$1')}'`,
$label: compute$Label(content),
$value: content,
}
const formatReg = new RegExp(Object.keys(format).map((m: string) => `\\${m}`).join('|'), 'g')
Expand Down
9 changes: 9 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,12 @@ export function matchRealType(content: string): string {
}
return realType
}

/**
* @description 计算 $label 的值
* @param content 内容
* @returns 具体的值
*/
export function compute$Label(content: string): string {
return JSON.stringify(content)
}

0 comments on commit a11bc49

Please sign in to comment.