mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Fix angle bracket path completions for link defs (#154182)
Fixes #153866
This commit is contained in:
parent
fc0bd9d377
commit
f6271dd82e
|
@ -193,7 +193,8 @@ export class MdVsCodePathCompletionProvider implements vscode.CompletionItemProv
|
|||
|
||||
const definitionLinkPrefixMatch = linePrefixText.match(this.definitionPattern);
|
||||
if (definitionLinkPrefixMatch) {
|
||||
const prefix = definitionLinkPrefixMatch[1];
|
||||
const isAngleBracketLink = definitionLinkPrefixMatch[1].startsWith('<');
|
||||
const prefix = definitionLinkPrefixMatch[1].slice(isAngleBracketLink ? 1 : 0);
|
||||
if (this.refLooksLikeUrl(prefix)) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -205,6 +206,7 @@ export class MdVsCodePathCompletionProvider implements vscode.CompletionItemProv
|
|||
linkTextStartPosition: position.translate({ characterDelta: -prefix.length }),
|
||||
linkSuffix: suffix ? suffix[0] : '',
|
||||
anchorInfo: this.getAnchorContext(prefix),
|
||||
skipEncoding: isAngleBracketLink,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -292,4 +292,22 @@ suite('Markdown: Path completions', () => {
|
|||
{ label: 'file.md', insertText: 'file.md' },
|
||||
]);
|
||||
});
|
||||
|
||||
test('Should support definition path with angle brackets', async () => {
|
||||
const workspace = new InMemoryMdWorkspace([
|
||||
new InMemoryDocument(workspacePath('a.md'), ''),
|
||||
new InMemoryDocument(workspacePath('b.md'), ''),
|
||||
new InMemoryDocument(workspacePath('sub with space/file.md'), ''),
|
||||
]);
|
||||
|
||||
const completions = await getCompletionsAtCursor(workspacePath('new.md'), joinLines(
|
||||
`[def]: <./${CURSOR}>`
|
||||
), workspace);
|
||||
|
||||
assertCompletionsEqual(completions, [
|
||||
{ label: 'a.md', insertText: 'a.md' },
|
||||
{ label: 'b.md', insertText: 'b.md' },
|
||||
{ label: 'sub with space/', insertText: 'sub with space/' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue