Skip to content

Commit

Permalink
Refactor color preview logic in serve.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
0Miles committed Feb 28, 2024
1 parent 4478f0b commit d222c99
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/language-server/src/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export default function serve() {
if (settings == null) {
return []
}
if (settings.previewColors == true && CheckFilesExclude(documentColor.textDocument.uri)) {
if (settings.previewColors && CheckFilesExclude(documentColor.textDocument.uri)) {
const documentUri = documentColor.textDocument.uri
const document = documents.get(documentUri)
if (document) {
Expand All @@ -210,10 +210,10 @@ export default function serve() {
return []
}

const colorIndexs = (await getDocumentColors(text, css))
const colorIndexes = (await getDocumentColors(text, css))

const colorIndexSet = new Set()
const colorInformations = colorIndexs
const colorInformation = colorIndexes
.filter(item => {
if (colorIndexSet.has(item.index.start)) {
return false
Expand All @@ -230,14 +230,14 @@ export default function serve() {
color: x.color
}))

return colorInformations
return colorInformation
}
}
return []
})

connection.onColorPresentation((params: ColorPresentationParams) => {
if (settings.previewColors == true && CheckFilesExclude(params.textDocument.uri)) {
if (settings.previewColors && CheckFilesExclude(params.textDocument.uri)) {
const document = documents.get(params.textDocument.uri)
if (document) {
const text = document.getText()
Expand Down

0 comments on commit d222c99

Please sign in to comment.