-
Notifications
You must be signed in to change notification settings - Fork 35.7k
Closed
Labels
*dev-questionVS Code Extension Development QuestionVS Code Extension Development QuestionmarkdownMarkdown support issuesMarkdown support issues
Milestone
Description
I'm trying to use vscode.open with DocumentLinkProvider. At present, only the first argument of vscode.open (the resource) seems to be respected. The other arguments are ignored.
Here's an example extension that demonstrates this issue:
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
// Open `abc.md` from workspace root and select a range in it
const commandUriWithOptions = vscode.Uri.parse(
createCommandUri('vscode.open', vscode.Uri.joinPath(vscode.workspace.workspaceFolders![0].uri, 'abc.md'), {
selection: new vscode.Range(2, 0, 5, 0),
})
);
// Open `abc.md` from workspace root besides the current file
const commandUriWithViewCol = vscode.Uri.parse(
createCommandUri('vscode.open', vscode.Uri.joinPath(vscode.workspace.workspaceFolders![0].uri, 'abc.md'), vscode.ViewColumn.Beside)
);
// Make sure basic command run on ext host side works
//vscode.commands.executeCommand('vscode.open', vscode.Uri.joinPath(vscode.workspace.workspaceFolders![0].uri, 'abc.md'), vscode.ViewColumn.Beside);
vscode.languages.registerDocumentLinkProvider('markdown', {
provideDocumentLinks: (doc) => {
return [
new vscode.DocumentLink(new vscode.Range(0, 0, 100, 0), commandUriWithViewCol)
];
}
});
}
function createCommandUri(command: string, ...args: any[]): string {
return `command:${command}?${encodeURIComponent(JSON.stringify(args))}`;
}To repo:
- Create
abc.mdin the root of your workspace. Add a few lines of content to it - Open another md file and open it
- Click on the link from the provider
Expected
This should open abc.md besides the current editor
Actual
abc.md is opened in the same view column
Metadata
Metadata
Assignees
Labels
*dev-questionVS Code Extension Development QuestionVS Code Extension Development QuestionmarkdownMarkdown support issuesMarkdown support issues