Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
42637a1d
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,发现更多精彩内容 >>
提交
42637a1d
编写于
4月 29, 2020
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make widget scrollable
Fixes #96499
上级
791156d9
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
41 addition
and
27 deletion
+41
-27
src/vs/workbench/contrib/terminal/browser/widgets/hoverWidget.ts
...workbench/contrib/terminal/browser/widgets/hoverWidget.ts
+41
-27
未找到文件。
src/vs/workbench/contrib/terminal/browser/widgets/hoverWidget.ts
浏览文件 @
42637a1d
...
...
@@ -14,18 +14,21 @@ import * as dom from 'vs/base/browser/dom';
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IHoverTarget
,
HorizontalAnchorSide
,
VerticalAnchorSide
}
from
'
vs/workbench/contrib/terminal/browser/widgets/widgets
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
DomScrollableElement
}
from
'
vs/base/browser/ui/scrollbar/scrollableElement
'
;
const
$
=
dom
.
$
;
export
class
HoverWidget
extends
Widget
{
private
readonly
_containerDomNode
:
HTMLElement
;
private
readonly
_domNode
:
HTMLElement
;
private
readonly
_messageListeners
=
new
DisposableStore
();
private
readonly
_mouseTracker
:
CompositeMouseTracker
;
private
readonly
_scrollbar
:
DomScrollableElement
;
private
_isDisposed
:
boolean
=
false
;
get
isDisposed
():
boolean
{
return
this
.
_isDisposed
;
}
get
domNode
():
HTMLElement
{
return
this
.
_
d
omNode
;
}
get
domNode
():
HTMLElement
{
return
this
.
_
containerD
omNode
;
}
private
readonly
_onDispose
=
new
Emitter
<
void
>
();
get
onDispose
():
Event
<
void
>
{
return
this
.
_onDispose
.
event
;
}
...
...
@@ -39,17 +42,24 @@ export class HoverWidget extends Widget {
@
IKeybindingService
private
readonly
_keybindingService
:
IKeybindingService
)
{
super
();
this
.
_containerDomNode
=
document
.
createElement
(
'
div
'
);
this
.
_containerDomNode
.
classList
.
add
(
'
terminal-hover-widget
'
,
'
fadeIn
'
,
'
monaco-editor-hover
'
,
'
xterm-hover
'
);
this
.
_containerDomNode
.
tabIndex
=
0
;
this
.
_containerDomNode
.
setAttribute
(
'
role
'
,
'
tooltip
'
);
this
.
_domNode
=
document
.
createElement
(
'
div
'
);
this
.
_domNode
.
classList
.
add
(
'
terminal-hover-widget
'
,
'
fadeIn
'
,
'
monaco-editor-hover
'
,
'
xterm-hover
'
);
this
.
_domNode
.
tabIndex
=
0
;
this
.
_domNode
.
setAttribute
(
'
role
'
,
'
tooltip
'
);
this
.
_domNode
.
className
=
'
monaco-editor-hover-content
'
;
this
.
_scrollbar
=
new
DomScrollableElement
(
this
.
_domNode
,
{});
this
.
_register
(
this
.
_scrollbar
);
this
.
_containerDomNode
.
appendChild
(
this
.
_scrollbar
.
getDomNode
());
// Don't allow mousedown out of the widget, otherwise preventDefault will call and text will
// not be selected.
this
.
onmousedown
(
this
.
_
d
omNode
,
e
=>
e
.
stopPropagation
());
this
.
onmousedown
(
this
.
_
containerD
omNode
,
e
=>
e
.
stopPropagation
());
// Hide hover on escape
this
.
onkeydown
(
this
.
_
d
omNode
,
e
=>
{
this
.
onkeydown
(
this
.
_
containerD
omNode
,
e
=>
{
if
(
e
.
equals
(
KeyCode
.
Escape
))
{
this
.
dispose
();
}
...
...
@@ -75,11 +85,11 @@ export class HoverWidget extends Widget {
this
.
_domNode
.
appendChild
(
statusBarElement
);
}
this
.
_mouseTracker
=
new
CompositeMouseTracker
([
this
.
_
d
omNode
,
...
_target
.
targetElements
]);
this
.
_mouseTracker
=
new
CompositeMouseTracker
([
this
.
_
containerD
omNode
,
...
_target
.
targetElements
]);
this
.
_register
(
this
.
_mouseTracker
.
onMouseOut
(()
=>
this
.
dispose
()));
this
.
_register
(
this
.
_mouseTracker
);
this
.
_container
.
appendChild
(
this
.
_
d
omNode
);
this
.
_container
.
appendChild
(
this
.
_
containerD
omNode
);
this
.
layout
();
}
...
...
@@ -106,51 +116,55 @@ export class HoverWidget extends Widget {
public
layout
():
void
{
const
anchor
=
this
.
_target
.
anchor
;
this
.
_domNode
.
classList
.
remove
(
'
right-aligned
'
);
this
.
_containerDomNode
.
classList
.
remove
(
'
right-aligned
'
);
this
.
_domNode
.
style
.
maxHeight
=
''
;
if
(
anchor
.
horizontalAnchorSide
===
HorizontalAnchorSide
.
Left
)
{
if
(
anchor
.
x
+
this
.
_
d
omNode
.
clientWidth
>
document
.
documentElement
.
clientWidth
)
{
if
(
anchor
.
x
+
this
.
_
containerD
omNode
.
clientWidth
>
document
.
documentElement
.
clientWidth
)
{
// Shift the hover to the left when part of it would get cut off
const
width
=
Math
.
round
(
this
.
_
d
omNode
.
clientWidth
);
this
.
_
d
omNode
.
style
.
width
=
`
${
width
-
1
}
px`
;
this
.
_
d
omNode
.
style
.
maxWidth
=
''
;
const
width
=
Math
.
round
(
this
.
_
containerD
omNode
.
clientWidth
);
this
.
_
containerD
omNode
.
style
.
width
=
`
${
width
-
1
}
px`
;
this
.
_
containerD
omNode
.
style
.
maxWidth
=
''
;
const
left
=
document
.
documentElement
.
clientWidth
-
width
-
1
;
this
.
_
d
omNode
.
style
.
left
=
`
${
left
}
px`
;
this
.
_
containerD
omNode
.
style
.
left
=
`
${
left
}
px`
;
// Right align if the right edge is closer to the anchor than the left edge
if
(
left
+
width
/
2
<
anchor
.
x
)
{
this
.
_
d
omNode
.
classList
.
add
(
'
right-aligned
'
);
this
.
_
containerD
omNode
.
classList
.
add
(
'
right-aligned
'
);
}
}
else
{
this
.
_
d
omNode
.
style
.
width
=
''
;
this
.
_
d
omNode
.
style
.
maxWidth
=
`
${
document
.
documentElement
.
clientWidth
-
anchor
.
x
-
1
}
px`
;
this
.
_
d
omNode
.
style
.
left
=
`
${
anchor
.
x
}
px`
;
this
.
_
containerD
omNode
.
style
.
width
=
''
;
this
.
_
containerD
omNode
.
style
.
maxWidth
=
`
${
document
.
documentElement
.
clientWidth
-
anchor
.
x
-
1
}
px`
;
this
.
_
containerD
omNode
.
style
.
left
=
`
${
anchor
.
x
}
px`
;
}
}
else
{
this
.
_
d
omNode
.
style
.
right
=
`
${
anchor
.
x
}
px`
;
this
.
_
containerD
omNode
.
style
.
right
=
`
${
anchor
.
x
}
px`
;
}
// Use fallback y value if there is not enough vertical space
if
(
anchor
.
verticalAnchorSide
===
VerticalAnchorSide
.
Bottom
)
{
if
(
anchor
.
y
+
this
.
_domNode
.
clientHeight
>
document
.
documentElement
.
clientHeight
)
{
this
.
_domNode
.
style
.
top
=
`
${
anchor
.
fallbackY
}
px`
;
if
(
anchor
.
y
+
this
.
_containerDomNode
.
clientHeight
>
document
.
documentElement
.
clientHeight
)
{
this
.
_containerDomNode
.
style
.
top
=
`
${
anchor
.
fallbackY
}
px`
;
this
.
_domNode
.
style
.
maxHeight
=
`
${
document
.
documentElement
.
clientHeight
-
anchor
.
fallbackY
}
px`
;
}
else
{
this
.
_domNode
.
style
.
bottom
=
`
${
anchor
.
y
}
px`
;
this
.
_containerDomNode
.
style
.
bottom
=
`
${
anchor
.
y
}
px`
;
this
.
_containerDomNode
.
style
.
maxHeight
=
''
;
}
}
else
{
if
(
anchor
.
y
+
this
.
_
d
omNode
.
clientHeight
>
document
.
documentElement
.
clientHeight
)
{
this
.
_
d
omNode
.
style
.
bottom
=
`
${
anchor
.
fallbackY
}
px`
;
if
(
anchor
.
y
+
this
.
_
containerD
omNode
.
clientHeight
>
document
.
documentElement
.
clientHeight
)
{
this
.
_
containerD
omNode
.
style
.
bottom
=
`
${
anchor
.
fallbackY
}
px`
;
}
else
{
this
.
_
d
omNode
.
style
.
top
=
`
${
anchor
.
y
}
px`
;
this
.
_
containerD
omNode
.
style
.
top
=
`
${
anchor
.
y
}
px`
;
}
}
this
.
_scrollbar
.
scanDomNode
();
}
public
focus
()
{
this
.
_
d
omNode
.
focus
();
this
.
_
containerD
omNode
.
focus
();
}
public
dispose
():
void
{
if
(
!
this
.
_isDisposed
)
{
this
.
_onDispose
.
fire
();
this
.
_
d
omNode
.
parentElement
?.
removeChild
(
this
.
domNode
);
this
.
_
containerD
omNode
.
parentElement
?.
removeChild
(
this
.
domNode
);
this
.
_messageListeners
.
dispose
();
this
.
_target
.
dispose
();
super
.
dispose
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录