fix completions and hovers inside `<style>` (fixes #334)
parent
b8dc88d699
commit
b7bf51f156
|
@ -476,14 +476,14 @@ function provideClassNameCompletions(
|
|||
position: Position,
|
||||
context?: CompletionContext
|
||||
): CompletionList {
|
||||
if (isHtmlContext(state, document, position) || isJsContext(state, document, position)) {
|
||||
return provideClassAttributeCompletions(state, document, position, context)
|
||||
}
|
||||
|
||||
if (isCssContext(state, document, position)) {
|
||||
return provideAtApplyCompletions(state, document, position)
|
||||
}
|
||||
|
||||
if (isHtmlContext(state, document, position) || isJsContext(state, document, position)) {
|
||||
return provideClassAttributeCompletions(state, document, position, context)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
|
@ -1,35 +1,24 @@
|
|||
import type { TextDocument, Position } from 'vscode-languageserver'
|
||||
import { isInsideTag, isVueDoc, isSvelteDoc, isHtmlDoc } from './html'
|
||||
import { isJsDoc } from './js'
|
||||
import { State } from './state'
|
||||
|
||||
export const CSS_LANGUAGES = [
|
||||
'css',
|
||||
'less',
|
||||
'postcss',
|
||||
'sass',
|
||||
'scss',
|
||||
'stylus',
|
||||
'sugarss',
|
||||
]
|
||||
export const CSS_LANGUAGES = ['css', 'less', 'postcss', 'sass', 'scss', 'stylus', 'sugarss']
|
||||
|
||||
export function isCssDoc(state: State, doc: TextDocument): boolean {
|
||||
const userCssLanguages = Object.keys(
|
||||
state.editor.userLanguages
|
||||
).filter((lang) => CSS_LANGUAGES.includes(state.editor.userLanguages[lang]))
|
||||
const userCssLanguages = Object.keys(state.editor.userLanguages).filter((lang) =>
|
||||
CSS_LANGUAGES.includes(state.editor.userLanguages[lang])
|
||||
)
|
||||
|
||||
return [...CSS_LANGUAGES, ...userCssLanguages].indexOf(doc.languageId) !== -1
|
||||
}
|
||||
|
||||
export function isCssContext(
|
||||
state: State,
|
||||
doc: TextDocument,
|
||||
position: Position
|
||||
): boolean {
|
||||
export function isCssContext(state: State, doc: TextDocument, position: Position): boolean {
|
||||
if (isCssDoc(state, doc)) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (isHtmlDoc(state, doc) || isVueDoc(doc) || isSvelteDoc(doc)) {
|
||||
if (isHtmlDoc(state, doc) || isVueDoc(doc) || isSvelteDoc(doc) || isJsDoc(state, doc)) {
|
||||
let str = doc.getText({
|
||||
start: { line: 0, character: 0 },
|
||||
end: position,
|
||||
|
|
Loading…
Reference in New Issue