mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 04:09:28 +00:00
Do not suggest own file for path completion. Fix #57384
This commit is contained in:
@@ -54,6 +54,7 @@ export function getPathCompletionParticipant(
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
result.items = [...suggestions, ...result.items];
|
||||
}
|
||||
};
|
||||
@@ -66,8 +67,13 @@ function providePathSuggestions(pathValue: string, position: Position, range: Ra
|
||||
? fullValue.slice(0, position.character - (range.start.character + 1))
|
||||
: fullValue.slice(0, position.character - range.start.character);
|
||||
const workspaceRoot = resolveWorkspaceRoot(document, workspaceFolders);
|
||||
const currentDocFsPath = URI.parse(document.uri).fsPath;
|
||||
|
||||
const paths = providePaths(valueBeforeCursor, currentDocFsPath, workspaceRoot).filter(p => {
|
||||
// Exclude current doc's path
|
||||
return path.resolve(currentDocFsPath, '../', p) !== currentDocFsPath;
|
||||
});
|
||||
|
||||
const paths = providePaths(valueBeforeCursor, URI.parse(document.uri).fsPath, workspaceRoot);
|
||||
const fullValueRange = isValueQuoted ? shiftRange(range, 1, -1) : range;
|
||||
const replaceRange = pathToReplaceRange(valueBeforeCursor, fullValue, fullValueRange);
|
||||
|
||||
|
||||
@@ -95,7 +95,6 @@ suite('Completions', () => {
|
||||
|
||||
assertCompletions(`html { background-image: url('|')`, {
|
||||
items: [
|
||||
{ label: 'about.css', resultText: `html { background-image: url('about.css')` },
|
||||
{ label: 'about.html', resultText: `html { background-image: url('about.html')` },
|
||||
]
|
||||
}, testUri, folders);
|
||||
@@ -156,7 +155,6 @@ suite('Completions', () => {
|
||||
|
||||
assertCompletions(`@import './|'`, {
|
||||
items: [
|
||||
{ label: 'about.css', resultText: `@import './about.css'` },
|
||||
{ label: 'about.html', resultText: `@import './about.html'` },
|
||||
]
|
||||
}, testUri, folders);
|
||||
|
||||
Reference in New Issue
Block a user