diff --git a/src/extension.ts b/src/extension.ts index 1766ec50b831b28d4806907e5645f3bf0c1eefcd..427e642c2f25e05636fc1d7f94d64dd3d0eb2be2 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -112,30 +112,21 @@ provideCompletionItems( document: vscode.TextDocument, position: vscode.Position ): vscode.CompletionItem[] { - const separator = config.options.separator || ':' - let str - const range: vscode.Range = new vscode.Range( new vscode.Position(Math.max(position.line - 5, 0), 0), position ) const text: string = document.getText(range) - let matches = text.match(regex) + let p = prefix + const separator = config.options.separator || ':' + + const matches = text.match(regex) if (matches) { - let parts = matches[matches.length - 1].split(' ') - str = parts[parts.length - 1] - } else if (languages.indexOf('html') !== -1) { - // match emmet style syntax - // e.g. .flex.items-center - let lineText = text.split('\n').pop() - matches = lineText.match(/^\s*[a-z-]*\.(.*?)$/i) - let parts = matches[matches.length - 1].split('.') - str = parts[parts.length - 1] - } + const parts = matches[matches.length - 1].split(' ') + const str = parts[parts.length - 1] - if (typeof str !== 'undefined') { const pth = str .replace(new RegExp(`${separator}`, 'g'), '.') .replace(/\.$/, '') @@ -351,7 +342,7 @@ createCompletionItemProvider( this._items, HTML_TYPES, /\bclass(Name)?=["']([^"']*)$/, // /\bclass(Name)?=(["'])(?!.*?\2)/ - ["'", '"', ' ', '.', separator], + ["'", '"', ' ', separator], tailwind.config ) )