提交 37c73f0c 编写于 作者: D Daniel Imms 提交者: GitHub

Merge pull request #31263 from cleidigh/terminal-clicklink/bug

Handle Alt+Click for terminal links. Fixes #30761
......@@ -72,7 +72,11 @@ export class TerminalLinkHandler {
const baseLocalLinkClause = _platform === platform.Platform.Windows ? winLocalLinkClause : unixLocalLinkClause;
// Append line and column number regex
this._localLinkPattern = new RegExp(`${baseLocalLinkClause}(${lineAndColumnClause})`);
this._xterm.setHypertextLinkHandler(this._wrapLinkHandler(() => true));
this._xterm.setHypertextLinkHandler(this._wrapLinkHandler(uri => {
this._handleHypertextLink(uri);
}));
this._xterm.setHypertextValidationCallback((uri: string, element: HTMLElement, callback: (isValid: boolean) => void) => {
this._validateWebLink(uri, element, callback);
});
......@@ -101,7 +105,6 @@ export class TerminalLinkHandler {
public registerLocalLinkHandler(): number {
const wrappedHandler = this._wrapLinkHandler(url => {
this._handleLocalLink(url);
return;
});
return this._xterm.registerLinkMatcher(this._localLinkRegex, wrappedHandler, {
......@@ -117,9 +120,10 @@ export class TerminalLinkHandler {
private _wrapLinkHandler(handler: (uri: string) => boolean | void): XtermLinkMatcherHandler {
return (event: MouseEvent, uri: string) => {
// Prevent default electron link handling so Alt+Click mode works normally
event.preventDefault();
// Require correct modifier on click
if (!this._isLinkActivationModifierDown(event)) {
event.preventDefault();
return false;
}
return handler(uri);
......@@ -164,6 +168,11 @@ export class TerminalLinkHandler {
callback(true);
}
private _handleHypertextLink(url: string): void {
let uri = Uri.parse(url);
this._openerService.open(uri);
}
private _isLinkActivationModifierDown(event: MouseEvent): boolean {
const editorConf = this._configurationService.getConfiguration<{ multiCursorModifier: 'ctrlCmd' | 'alt' }>('editor');
if (editorConf.multiCursorModifier === 'ctrlCmd') {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册