forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes microsoft#119357 Fixes microsoft#89966 In order to implement this, I also added API that lets markdown strings allow just a subset of command uris. This is required because we have to use a command to implement the links, but do not want to allow just any command to be run
- Loading branch information
Showing
15 changed files
with
169 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
extensions/typescript-language-features/src/commands/openJsDocLink.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as vscode from 'vscode'; | ||
import type * as Proto from '../protocol'; | ||
import TypeScriptServiceClientHost from '../typeScriptServiceClientHost'; | ||
import { Lazy } from '../utils/lazy'; | ||
import { Command } from './commandManager'; | ||
|
||
|
||
export class OpenJsDocLinkCommand implements Command { | ||
public static readonly id = '_typescript.openJsDocLink'; | ||
public readonly id = OpenJsDocLinkCommand.id; | ||
|
||
public static createCommandUri(fileSpan: Proto.FileSpan) { | ||
return `command:${OpenJsDocLinkCommand.id}?${encodeURIComponent(JSON.stringify({ span: fileSpan }))}`; | ||
} | ||
|
||
public constructor( | ||
private readonly lazyClientHost: Lazy<TypeScriptServiceClientHost> | ||
) { } | ||
|
||
public async execute(args: { span: Proto.FileSpan }) { | ||
if (!this.lazyClientHost.hasValue) { | ||
return; | ||
} | ||
|
||
const uri = this.lazyClientHost.value.serviceClient.toResource(args.span.file); | ||
const doc = await vscode.workspace.openTextDocument(uri); | ||
const editor = await vscode.window.showTextDocument(doc); | ||
|
||
const pos = new vscode.Position(args.span.start.line - 1, args.span.start.offset - 1); | ||
const selection = new vscode.Selection(pos, pos); | ||
editor.revealRange(selection, vscode.TextEditorRevealType.InCenterIfOutsideViewport); | ||
editor.selection = selection; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.