Skip to content

Commit 4c7cec8

Browse files
committed
Check document exists
1 parent a3928db commit 4c7cec8

File tree

3 files changed

+3
-0
lines changed

3 files changed

+3
-0
lines changed

packages/tailwindcss-language-server/src/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,7 @@ async function createProjectService(
11141114
},
11151115
async onColorPresentation(params: ColorPresentationParams): Promise<ColorPresentation[]> {
11161116
let document = documentService.getDocument(params.textDocument.uri)
1117+
if (!document) return []
11171118
let className = document.getText(params.range)
11181119
let match = className.match(
11191120
new RegExp(`-\\[(${colorNames.join('|')}|(?:(?:#|rgba?\\(|hsla?\\())[^\\]]+)\\]$`, 'i')

packages/tailwindcss-language-service/src/codeActions/codeActionProvider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ async function getDiagnosticsFromCodeActionParams(
2424
only?: DiagnosticKind[]
2525
): Promise<AugmentedDiagnostic[]> {
2626
let document = state.editor.documents.get(params.textDocument.uri)
27+
if (!document) return []
2728
let diagnostics = await doValidate(state, document, only)
2829

2930
return params.context.diagnostics

packages/tailwindcss-language-service/src/codeActions/provideInvalidApplyCodeActions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export async function provideInvalidApplyCodeActions(
2525
diagnostic: InvalidApplyDiagnostic
2626
): Promise<CodeAction[]> {
2727
let document = state.editor.documents.get(params.textDocument.uri)
28+
if (!document) return []
2829
let documentText = getTextWithoutComments(document, 'css')
2930
let cssRange: Range
3031
let cssText = documentText

0 commit comments

Comments
 (0)