Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9bf3f954
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9bf3f954
编写于
2月 25, 2020
作者:
J
Jon Bockhorst
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix terminal Follow Link handlers
上级
858457d2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
20 deletion
+25
-20
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
...vs/workbench/contrib/terminal/browser/terminalInstance.ts
+1
-1
src/vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts
...workbench/contrib/terminal/browser/terminalLinkHandler.ts
+20
-8
src/vs/workbench/contrib/terminal/browser/terminalWidgetManager.ts
...rkbench/contrib/terminal/browser/terminalWidgetManager.ts
+4
-11
未找到文件。
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
浏览文件 @
9bf3f954
...
...
@@ -669,7 +669,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
this
.
_refreshSelectionContextKey
();
}));
const
widgetManager
=
new
TerminalWidgetManager
(
this
.
_wrapperElement
,
this
.
_openerService
);
const
widgetManager
=
new
TerminalWidgetManager
(
this
.
_wrapperElement
);
this
.
_widgetManager
=
widgetManager
;
this
.
_processManager
.
onProcessReady
(()
=>
this
.
_linkHandler
?.
setWidgetManager
(
widgetManager
));
...
...
src/vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts
浏览文件 @
9bf3f954
...
...
@@ -72,7 +72,7 @@ export class TerminalLinkHandler {
private
_processCwd
:
string
|
undefined
;
private
_gitDiffPreImagePattern
:
RegExp
;
private
_gitDiffPostImagePattern
:
RegExp
;
private
readonly
_tooltipCallback
:
(
event
:
MouseEvent
,
uri
:
string
,
location
:
IViewportRange
)
=>
boolean
|
void
;
private
readonly
_tooltipCallback
:
(
event
:
MouseEvent
,
uri
:
string
,
location
:
IViewportRange
,
linkHandler
:
(
url
:
string
)
=>
void
)
=>
boolean
|
void
;
private
readonly
_leaveCallback
:
()
=>
void
;
constructor
(
...
...
@@ -90,7 +90,7 @@ export class TerminalLinkHandler {
// Matches '+++ b/src/file1', capturing 'src/file1' in group 1
this
.
_gitDiffPostImagePattern
=
/^
\+\+\+
b
\/(\S
*
)
/
;
this
.
_tooltipCallback
=
(
e
:
MouseEvent
,
uri
:
string
,
location
:
IViewportRange
)
=>
{
this
.
_tooltipCallback
=
(
e
:
MouseEvent
,
uri
:
string
,
location
:
IViewportRange
,
linkHandler
:
(
url
:
string
)
=>
void
)
=>
{
if
(
!
this
.
_widgetManager
)
{
return
;
}
...
...
@@ -117,7 +117,7 @@ export class TerminalLinkHandler {
const
leftPosition
=
location
.
start
.
x
*
(
charWidth
!
+
(
font
.
letterSpacing
/
window
.
devicePixelRatio
));
const
bottomPosition
=
offsetRow
*
(
Math
.
ceil
(
charHeight
!
*
window
.
devicePixelRatio
)
*
font
.
lineHeight
)
/
window
.
devicePixelRatio
;
this
.
_widgetManager
.
showMessage
(
leftPosition
,
bottomPosition
,
this
.
_getLinkHoverString
(
uri
),
verticalAlignment
);
this
.
_widgetManager
.
showMessage
(
leftPosition
,
bottomPosition
,
this
.
_getLinkHoverString
(
uri
),
verticalAlignment
,
linkHandler
);
}
else
{
const
target
=
(
e
.
target
as
HTMLElement
);
const
colWidth
=
target
.
offsetWidth
/
this
.
_xterm
.
cols
;
...
...
@@ -125,7 +125,7 @@ export class TerminalLinkHandler {
const
leftPosition
=
location
.
start
.
x
*
colWidth
;
const
bottomPosition
=
offsetRow
*
rowHeight
;
this
.
_widgetManager
.
showMessage
(
leftPosition
,
bottomPosition
,
this
.
_getLinkHoverString
(
uri
),
verticalAlignment
);
this
.
_widgetManager
.
showMessage
(
leftPosition
,
bottomPosition
,
this
.
_getLinkHoverString
(
uri
),
verticalAlignment
,
linkHandler
);
}
};
this
.
_leaveCallback
=
()
=>
{
...
...
@@ -152,9 +152,12 @@ export class TerminalLinkHandler {
}
public
registerCustomLinkHandler
(
regex
:
RegExp
,
handler
:
(
uri
:
string
)
=>
void
,
matchIndex
?:
number
,
validationCallback
?:
XtermLinkMatcherValidationCallback
):
number
{
const
tooltipCallback
=
(
event
:
MouseEvent
,
uri
:
string
,
location
:
IViewportRange
)
=>
{
this
.
_tooltipCallback
(
event
,
uri
,
location
,
handler
);
};
const
options
:
ILinkMatcherOptions
=
{
matchIndex
,
tooltipCallback
:
this
.
_tooltipCallback
,
tooltipCallback
,
leaveCallback
:
this
.
_leaveCallback
,
willLinkActivate
:
(
e
:
MouseEvent
)
=>
this
.
_isLinkActivationModifierDown
(
e
),
priority
:
CUSTOM_LINK_PRIORITY
...
...
@@ -173,9 +176,12 @@ export class TerminalLinkHandler {
const
wrappedHandler
=
this
.
_wrapLinkHandler
(
uri
=>
{
this
.
_handleHypertextLink
(
uri
);
});
const
tooltipCallback
=
(
event
:
MouseEvent
,
uri
:
string
,
location
:
IViewportRange
)
=>
{
this
.
_tooltipCallback
(
event
,
uri
,
location
,
this
.
_handleHypertextLink
.
bind
(
this
));
};
this
.
_xterm
.
loadAddon
(
new
WebLinksAddon
(
wrappedHandler
,
{
validationCallback
:
(
uri
:
string
,
callback
:
(
isValid
:
boolean
)
=>
void
)
=>
this
.
_validateWebLink
(
uri
,
callback
),
tooltipCallback
:
this
.
_tooltipCallback
,
tooltipCallback
,
leaveCallback
:
this
.
_leaveCallback
,
willLinkActivate
:
(
e
:
MouseEvent
)
=>
this
.
_isLinkActivationModifierDown
(
e
)
}));
...
...
@@ -186,9 +192,12 @@ export class TerminalLinkHandler {
const
wrappedHandler
=
this
.
_wrapLinkHandler
(
url
=>
{
this
.
_handleLocalLink
(
url
);
});
const
tooltipCallback
=
(
event
:
MouseEvent
,
uri
:
string
,
location
:
IViewportRange
)
=>
{
this
.
_tooltipCallback
(
event
,
uri
,
location
,
this
.
_handleLocalLink
.
bind
(
this
));
};
this
.
_xterm
.
registerLinkMatcher
(
this
.
_localLinkRegex
,
wrappedHandler
,
{
validationCallback
:
(
uri
:
string
,
callback
:
(
isValid
:
boolean
)
=>
void
)
=>
this
.
_validateLocalLink
(
uri
,
callback
),
tooltipCallback
:
this
.
_tooltipCallback
,
tooltipCallback
,
leaveCallback
:
this
.
_leaveCallback
,
willLinkActivate
:
(
e
:
MouseEvent
)
=>
this
.
_isLinkActivationModifierDown
(
e
),
priority
:
LOCAL_LINK_PRIORITY
...
...
@@ -199,10 +208,13 @@ export class TerminalLinkHandler {
const
wrappedHandler
=
this
.
_wrapLinkHandler
(
url
=>
{
this
.
_handleLocalLink
(
url
);
});
const
tooltipCallback
=
(
event
:
MouseEvent
,
uri
:
string
,
location
:
IViewportRange
)
=>
{
this
.
_tooltipCallback
(
event
,
uri
,
location
,
this
.
_handleLocalLink
.
bind
(
this
));
};
const
options
=
{
matchIndex
:
1
,
validationCallback
:
(
uri
:
string
,
callback
:
(
isValid
:
boolean
)
=>
void
)
=>
this
.
_validateLocalLink
(
uri
,
callback
),
tooltipCallback
:
this
.
_tooltipCallback
,
tooltipCallback
,
leaveCallback
:
this
.
_leaveCallback
,
willLinkActivate
:
(
e
:
MouseEvent
)
=>
this
.
_isLinkActivationModifierDown
(
e
),
priority
:
LOCAL_LINK_PRIORITY
...
...
src/vs/workbench/contrib/terminal/browser/terminalWidgetManager.ts
浏览文件 @
9bf3f954
...
...
@@ -6,8 +6,6 @@
import
{
IDisposable
,
dispose
,
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
IMarkdownString
}
from
'
vs/base/common/htmlContent
'
;
import
{
renderMarkdown
}
from
'
vs/base/browser/markdownRenderer
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
export
enum
WidgetVerticalAlignment
{
Bottom
,
...
...
@@ -25,7 +23,6 @@ export class TerminalWidgetManager implements IDisposable {
constructor
(
terminalWrapper
:
HTMLElement
,
private
readonly
_openerService
:
IOpenerService
)
{
this
.
_container
=
document
.
createElement
(
'
div
'
);
this
.
_container
.
classList
.
add
(
'
terminal-widget-overlay
'
);
...
...
@@ -53,13 +50,13 @@ export class TerminalWidgetManager implements IDisposable {
mutationObserver
.
observe
(
this
.
_xtermViewport
,
{
attributes
:
true
,
attributeFilter
:
[
'
style
'
]
});
}
public
showMessage
(
left
:
number
,
y
:
number
,
text
:
IMarkdownString
,
verticalAlignment
:
WidgetVerticalAlignment
=
WidgetVerticalAlignment
.
Bottom
):
void
{
public
showMessage
(
left
:
number
,
y
:
number
,
text
:
IMarkdownString
,
verticalAlignment
:
WidgetVerticalAlignment
=
WidgetVerticalAlignment
.
Bottom
,
linkHandler
:
(
url
:
string
)
=>
void
):
void
{
if
(
!
this
.
_container
)
{
return
;
}
dispose
(
this
.
_messageWidget
);
this
.
_messageListeners
.
clear
();
this
.
_messageWidget
=
new
MessageWidget
(
this
.
_container
,
left
,
y
,
text
,
verticalAlignment
,
this
.
_openerService
);
this
.
_messageWidget
=
new
MessageWidget
(
this
.
_container
,
left
,
y
,
text
,
verticalAlignment
,
linkHandler
);
}
public
closeMessage
():
void
{
...
...
@@ -110,11 +107,11 @@ class MessageWidget {
private
_y
:
number
,
private
_text
:
IMarkdownString
,
private
_verticalAlignment
:
WidgetVerticalAlignment
,
private
readonly
_openerService
:
IOpenerService
private
_linkHandler
:
(
url
:
string
)
=>
void
)
{
this
.
_domNode
=
renderMarkdown
(
this
.
_text
,
{
actionHandler
:
{
callback
:
this
.
_
handleLinkClicked
.
bind
(
this
)
,
callback
:
this
.
_
linkHandler
,
disposeables
:
this
.
_messageListeners
}
});
...
...
@@ -149,8 +146,4 @@ class MessageWidget {
this
.
_messageListeners
.
dispose
();
}
private
_handleLinkClicked
(
content
:
string
)
{
this
.
_openerService
.
open
(
URI
.
parse
(
content
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录