Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
342f8123
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,发现更多精彩内容 >>
未验证
提交
342f8123
编写于
10月 25, 2019
作者:
D
Daniel Imms
提交者:
GitHub
10月 25, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #83175 from jmbockhorst/link
Change terminal link hover widget position to be consistent
上级
992e25cf
9fce3407
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
51 addition
and
13 deletion
+51
-13
src/vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts
...workbench/contrib/terminal/browser/terminalLinkHandler.ts
+30
-7
src/vs/workbench/contrib/terminal/browser/terminalWidgetManager.ts
...rkbench/contrib/terminal/browser/terminalWidgetManager.ts
+21
-6
未找到文件。
src/vs/workbench/contrib/terminal/browser/terminalLinkHandler.ts
浏览文件 @
342f8123
...
...
@@ -7,13 +7,13 @@ import * as nls from 'vs/nls';
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
TerminalWidgetManager
}
from
'
vs/workbench/contrib/terminal/browser/terminalWidgetManager
'
;
import
{
TerminalWidgetManager
,
WidgetVerticalAlignment
}
from
'
vs/workbench/contrib/terminal/browser/terminalWidgetManager
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ITerminalProcessManager
,
ITerminalConfigHelper
}
from
'
vs/workbench/contrib/terminal/common/terminal
'
;
import
{
ITextEditorSelection
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
Terminal
,
ILinkMatcherOptions
}
from
'
xterm
'
;
import
{
Terminal
,
ILinkMatcherOptions
,
IViewportRange
}
from
'
xterm
'
;
import
{
REMOTE_HOST_SCHEME
}
from
'
vs/platform/remote/common/remoteHosts
'
;
import
{
posix
,
win32
}
from
'
vs/base/common/path
'
;
import
{
ITerminalInstanceService
}
from
'
vs/workbench/contrib/terminal/browser/terminal
'
;
...
...
@@ -71,7 +71,7 @@ export class TerminalLinkHandler {
private
_processCwd
:
string
|
undefined
;
private
_gitDiffPreImagePattern
:
RegExp
;
private
_gitDiffPostImagePattern
:
RegExp
;
private
readonly
_tooltipCallback
:
(
event
:
MouseEvent
,
uri
:
string
)
=>
boolean
|
void
;
private
readonly
_tooltipCallback
:
(
event
:
MouseEvent
,
uri
:
string
,
location
:
IViewportRange
)
=>
boolean
|
void
;
private
readonly
_leaveCallback
:
()
=>
void
;
constructor
(
...
...
@@ -89,15 +89,38 @@ export class TerminalLinkHandler {
// Matches '+++ b/src/file1', capturing 'src/file1' in group 1
this
.
_gitDiffPostImagePattern
=
/^
\+\+\+
b
\/(\S
*
)
/
;
this
.
_tooltipCallback
=
(
e
:
MouseEvent
)
=>
{
this
.
_tooltipCallback
=
(
e
:
MouseEvent
,
uri
:
string
,
location
:
IViewportRange
)
=>
{
if
(
!
this
.
_widgetManager
)
{
return
;
}
// Get the row bottom up
let
offsetRow
=
this
.
_xterm
.
rows
-
location
.
start
.
row
+
1
;
let
verticalAlignment
=
WidgetVerticalAlignment
.
Bottom
;
// Show the tooltip on the top of the next row to avoid obscuring the first row
if
(
location
.
start
.
row
===
1
)
{
offsetRow
--
;
verticalAlignment
=
WidgetVerticalAlignment
.
Top
;
}
if
(
this
.
_configHelper
.
config
.
rendererType
===
'
dom
'
)
{
const
target
=
(
e
.
target
as
HTMLElement
);
this
.
_widgetManager
.
showMessage
(
target
.
offsetLeft
,
target
.
offsetTop
,
this
.
_getLinkHoverString
());
const
font
=
this
.
_configHelper
.
getFont
();
const
charWidth
=
font
.
charWidth
;
const
charHeight
=
font
.
charHeight
;
const
leftPosition
=
(
location
.
start
.
col
-
1
)
*
(
charWidth
!
+
(
font
.
letterSpacing
/
window
.
devicePixelRatio
));
const
bottomPosition
=
offsetRow
*
(
Math
.
ceil
(
charHeight
!
*
window
.
devicePixelRatio
)
*
font
.
lineHeight
)
/
window
.
devicePixelRatio
;
this
.
_widgetManager
.
showMessage
(
leftPosition
,
bottomPosition
,
this
.
_getLinkHoverString
(),
verticalAlignment
);
}
else
{
this
.
_widgetManager
.
showMessage
(
e
.
offsetX
,
e
.
offsetY
,
this
.
_getLinkHoverString
());
const
target
=
(
e
.
target
as
HTMLElement
);
const
colWidth
=
target
.
offsetWidth
/
this
.
_xterm
.
cols
;
const
rowHeight
=
target
.
offsetHeight
/
this
.
_xterm
.
rows
;
const
leftPosition
=
(
location
.
start
.
col
-
1
)
*
colWidth
;
const
bottomPosition
=
offsetRow
*
rowHeight
;
this
.
_widgetManager
.
showMessage
(
leftPosition
,
bottomPosition
,
this
.
_getLinkHoverString
(),
verticalAlignment
);
}
};
this
.
_leaveCallback
=
()
=>
{
...
...
src/vs/workbench/contrib/terminal/browser/terminalWidgetManager.ts
浏览文件 @
342f8123
...
...
@@ -5,6 +5,11 @@
import
{
IDisposable
,
dispose
,
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
export
enum
WidgetVerticalAlignment
{
Bottom
,
Top
}
const
WIDGET_HEIGHT
=
29
;
export
class
TerminalWidgetManager
implements
IDisposable
{
...
...
@@ -43,13 +48,13 @@ export class TerminalWidgetManager implements IDisposable {
mutationObserver
.
observe
(
this
.
_xtermViewport
,
{
attributes
:
true
,
attributeFilter
:
[
'
style
'
]
});
}
public
showMessage
(
left
:
number
,
top
:
number
,
text
:
string
):
void
{
public
showMessage
(
left
:
number
,
y
:
number
,
text
:
string
,
verticalAlignment
:
WidgetVerticalAlignment
=
WidgetVerticalAlignment
.
Bottom
):
void
{
if
(
!
this
.
_container
)
{
return
;
}
dispose
(
this
.
_messageWidget
);
this
.
_messageListeners
.
clear
();
this
.
_messageWidget
=
new
MessageWidget
(
this
.
_container
,
left
,
top
,
tex
t
);
this
.
_messageWidget
=
new
MessageWidget
(
this
.
_container
,
left
,
y
,
text
,
verticalAlignmen
t
);
}
public
closeMessage
():
void
{
...
...
@@ -71,9 +76,10 @@ class MessageWidget {
private
_domNode
:
HTMLDivElement
;
public
get
left
():
number
{
return
this
.
_left
;
}
public
get
top
():
number
{
return
this
.
_top
;
}
public
get
y
():
number
{
return
this
.
_y
;
}
public
get
text
():
string
{
return
this
.
_text
;
}
public
get
domNode
():
HTMLElement
{
return
this
.
_domNode
;
}
public
get
verticalAlignment
():
WidgetVerticalAlignment
{
return
this
.
_verticalAlignment
;
}
public
static
fadeOut
(
messageWidget
:
MessageWidget
):
IDisposable
{
let
handle
:
any
;
...
...
@@ -91,13 +97,22 @@ class MessageWidget {
constructor
(
private
_container
:
HTMLElement
,
private
_left
:
number
,
private
_top
:
number
,
private
_text
:
string
private
_y
:
number
,
private
_text
:
string
,
private
_verticalAlignment
:
WidgetVerticalAlignment
)
{
this
.
_domNode
=
document
.
createElement
(
'
div
'
);
this
.
_domNode
.
style
.
position
=
'
absolute
'
;
this
.
_domNode
.
style
.
left
=
`
${
_left
}
px`
;
this
.
_domNode
.
style
.
bottom
=
`
${
_container
.
offsetHeight
-
Math
.
max
(
_top
,
WIDGET_HEIGHT
)}
px`
;
if
(
this
.
verticalAlignment
===
WidgetVerticalAlignment
.
Top
)
{
// Y position is to the top of the widget
this
.
_domNode
.
style
.
bottom
=
`
${
Math
.
max
(
_y
,
WIDGET_HEIGHT
)
-
WIDGET_HEIGHT
}
px`
;
}
else
{
// Y position is to the bottom of the widget
this
.
_domNode
.
style
.
bottom
=
`
${
Math
.
min
(
_y
,
_container
.
offsetHeight
-
WIDGET_HEIGHT
)}
px`
;
}
this
.
_domNode
.
classList
.
add
(
'
terminal-message-widget
'
,
'
fadeIn
'
);
this
.
_domNode
.
textContent
=
_text
;
this
.
_container
.
appendChild
(
this
.
_domNode
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录