Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f17d0144
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,发现更多精彩内容 >>
提交
f17d0144
编写于
9月 16, 2020
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support IHoverOptions.anchorPosition
Fixes #106871
上级
d80f324e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
8 deletion
+32
-8
src/vs/workbench/contrib/terminal/browser/widgets/terminalHoverWidget.ts
...h/contrib/terminal/browser/widgets/terminalHoverWidget.ts
+3
-1
src/vs/workbench/services/hover/browser/hover.ts
src/vs/workbench/services/hover/browser/hover.ts
+7
-0
src/vs/workbench/services/hover/browser/hoverWidget.ts
src/vs/workbench/services/hover/browser/hoverWidget.ts
+22
-7
未找到文件。
src/vs/workbench/contrib/terminal/browser/widgets/terminalHoverWidget.ts
浏览文件 @
f17d0144
...
...
@@ -12,6 +12,7 @@ import type { IViewportRange } from 'xterm';
import
{
IHoverTarget
,
IHoverService
}
from
'
vs/workbench/services/hover/browser/hover
'
;
import
{
registerThemingParticipant
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
editorHoverHighlight
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
AnchorPosition
}
from
'
vs/base/browser/ui/contextview/contextview
'
;
const
$
=
dom
.
$
;
...
...
@@ -46,7 +47,8 @@ export class TerminalHover extends Disposable implements ITerminalWidget {
text
:
this
.
_text
,
linkHandler
:
this
.
_linkHandler
,
// .xterm-hover lets xterm know that the hover is part of a link
additionalClasses
:
[
'
xterm-hover
'
]
additionalClasses
:
[
'
xterm-hover
'
],
anchorPosition
:
AnchorPosition
.
BELOW
});
if
(
hover
)
{
this
.
_register
(
hover
);
...
...
src/vs/workbench/services/hover/browser/hover.ts
浏览文件 @
f17d0144
...
...
@@ -6,6 +6,7 @@
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IMarkdownString
}
from
'
vs/base/common/htmlContent
'
;
import
{
AnchorPosition
}
from
'
vs/base/browser/ui/contextview/contextview
'
;
export
const
IHoverService
=
createDecorator
<
IHoverService
>
(
'
hoverService
'
);
...
...
@@ -79,6 +80,12 @@ export interface IHoverOptions {
* - Markdown that contains no links where selection is not important
*/
hideOnHover
?:
boolean
;
/**
* Whether to anchor the hover above (default) or below the target. This option will be ignored
* if there is not enough room to layout the hover in the specified anchor position.
*/
anchorPosition
?:
AnchorPosition
;
}
export
interface
IHoverAction
{
...
...
src/vs/workbench/services/hover/browser/hoverWidget.ts
浏览文件 @
f17d0144
...
...
@@ -30,7 +30,7 @@ export class HoverWidget extends Widget {
private
readonly
_linkHandler
:
(
url
:
string
)
=>
any
;
private
_isDisposed
:
boolean
=
false
;
private
_anchor
:
AnchorPosition
=
AnchorPosition
.
ABOVE
;
private
_anchor
:
AnchorPosition
;
private
_x
:
number
=
0
;
private
_y
:
number
=
0
;
...
...
@@ -60,12 +60,13 @@ export class HoverWidget extends Widget {
this
.
_target
=
'
targetElements
'
in
options
.
target
?
options
.
target
:
new
ElementHoverTarget
(
options
.
target
);
this
.
_hover
=
this
.
_register
(
new
BaseHoverWidget
());
this
.
_hover
.
containerDomNode
.
classList
.
add
(
'
workbench-hover
'
,
'
fadeIn
'
);
if
(
options
.
additionalClasses
)
{
this
.
_hover
.
containerDomNode
.
classList
.
add
(...
options
.
additionalClasses
);
}
this
.
_anchor
=
options
.
anchorPosition
??
AnchorPosition
.
ABOVE
;
// Don't allow mousedown out of the widget, otherwise preventDefault will call and text will
// not be selected.
this
.
onmousedown
(
this
.
_hover
.
containerDomNode
,
e
=>
e
.
stopPropagation
());
...
...
@@ -165,12 +166,26 @@ export class HoverWidget extends Widget {
}
// Get vertical alignment and position
const
targetTop
=
Math
.
min
(...
targetBounds
.
map
(
e
=>
e
.
top
));
if
(
targetTop
-
this
.
_hover
.
containerDomNode
.
clientHeight
<
0
)
{
this
.
_anchor
=
AnchorPosition
.
BELOW
;
this
.
_y
=
Math
.
max
(...
targetBounds
.
map
(
e
=>
e
.
bottom
))
-
2
;
if
(
this
.
_anchor
===
AnchorPosition
.
ABOVE
)
{
const
targetTop
=
Math
.
min
(...
targetBounds
.
map
(
e
=>
e
.
top
));
if
(
targetTop
-
this
.
_hover
.
containerDomNode
.
clientHeight
<
0
)
{
const
targetBottom
=
Math
.
max
(...
targetBounds
.
map
(
e
=>
e
.
bottom
));
this
.
_anchor
=
AnchorPosition
.
BELOW
;
this
.
_y
=
targetBottom
-
2
;
}
else
{
this
.
_y
=
targetTop
;
}
}
else
{
this
.
_y
=
targetTop
;
console
.
log
(
'
below
'
);
const
targetBottom
=
Math
.
max
(...
targetBounds
.
map
(
e
=>
e
.
bottom
));
if
(
targetBottom
+
this
.
_hover
.
containerDomNode
.
clientHeight
>
window
.
innerHeight
)
{
console
.
log
(
targetBottom
,
this
.
_hover
.
containerDomNode
.
clientHeight
,
window
.
innerHeight
);
const
targetTop
=
Math
.
min
(...
targetBounds
.
map
(
e
=>
e
.
top
));
this
.
_anchor
=
AnchorPosition
.
ABOVE
;
this
.
_y
=
targetTop
;
}
else
{
this
.
_y
=
targetBottom
-
2
;
}
}
this
.
_hover
.
onContentsChanged
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录