mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
[css] .asar file breaks CSS path completion. Fixes #46638
This commit is contained in:
@@ -10,7 +10,7 @@ import URI from 'vscode-uri';
|
||||
|
||||
import { TextDocument, CompletionList, CompletionItemKind, CompletionItem, TextEdit, Range, Position } from 'vscode-languageserver-types';
|
||||
import { WorkspaceFolder } from 'vscode-languageserver';
|
||||
import { ICompletionParticipant } from 'vscode-css-languageservice';
|
||||
import { ICompletionParticipant, URILiteralCompletionContext } from 'vscode-css-languageservice';
|
||||
|
||||
import { startsWith } from './utils/strings';
|
||||
|
||||
@@ -20,7 +20,7 @@ export function getPathCompletionParticipant(
|
||||
result: CompletionList
|
||||
): ICompletionParticipant {
|
||||
return {
|
||||
onURILiteralValue: (context: { uriValue: string, position: Position, range: Range; }) => {
|
||||
onURILiteralValue: (context: URILiteralCompletionContext) => {
|
||||
if (!workspaceFolders || workspaceFolders.length === 0) {
|
||||
return;
|
||||
}
|
||||
@@ -91,7 +91,11 @@ export function providePathSuggestions(value: string, range: Range, activeDocFsP
|
||||
}
|
||||
|
||||
const isDir = (p: string) => {
|
||||
return fs.statSync(p).isDirectory();
|
||||
try {
|
||||
return fs.statSync(p).isDirectory();
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
function resolveWorkspaceRoot(activeDoc: TextDocument, workspaceFolders: WorkspaceFolder[]): string | undefined {
|
||||
|
||||
@@ -77,5 +77,19 @@ suite('Completions', () => {
|
||||
{ label: 'src/', resultText: `html { background-image: url('../src/')` }
|
||||
]
|
||||
}, testUri);
|
||||
|
||||
assertCompletions(`html { background-image: url('../src/a|')`, {
|
||||
items: [
|
||||
{ label: 'feature.js', resultText: `html { background-image: url('../src/feature.js')` },
|
||||
{ label: 'data/', resultText: `html { background-image: url('../src/data/')` },
|
||||
{ label: 'test.js', resultText: `html { background-image: url('../src/test.js')` }
|
||||
]
|
||||
}, testUri);
|
||||
|
||||
assertCompletions(`html { background-image: url('../src/data/f|.asar')`, {
|
||||
items: [
|
||||
{ label: 'foo.asar', resultText: `html { background-image: url('../src/data/foo.asar')` }
|
||||
]
|
||||
}, testUri);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
Reference in New Issue
Block a user