Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
eae2a774
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,发现更多精彩内容 >>
提交
eae2a774
编写于
5月 25, 2017
作者:
A
Alex Dima
提交者:
Dirk Baeumer
5月 26, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Show correct link hover when links open with Alt
上级
17ea00ea
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
43 addition
and
24 deletion
+43
-24
src/vs/editor/contrib/links/browser/links.ts
src/vs/editor/contrib/links/browser/links.ts
+43
-24
未找到文件。
src/vs/editor/contrib/links/browser/links.ts
浏览文件 @
eae2a774
...
...
@@ -27,15 +27,40 @@ import { Position } from 'vs/editor/common/core/position';
import
{
ModelDecorationOptions
}
from
"
vs/editor/common/model/textModelWithDecorations
"
;
import
{
ClickLinkGesture
,
ClickLinkMouseEvent
,
ClickLinkKeyboardEvent
}
from
"
vs/editor/contrib/goToDeclaration/browser/clickLinkGesture
"
;
const
HOVER_MESSAGE_GENERAL
=
(
const
HOVER_MESSAGE_GENERAL
_META
=
(
platform
.
isMacintosh
?
nls
.
localize
(
'
links.navigate.mac
'
,
"
Cmd + click to follow link
"
)
:
nls
.
localize
(
'
links.navigate
'
,
"
Ctrl + click to follow link
"
)
);
const
HOVER_MESSAGE_GENERAL_ALT
=
nls
.
localize
(
'
links.navigate.al
'
,
"
Alt + click to follow link
"
);
const
decoration
=
{
meta
:
ModelDecorationOptions
.
register
({
stickiness
:
editorCommon
.
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
inlineClassName
:
'
detected-link
'
,
hoverMessage
:
HOVER_MESSAGE_GENERAL_META
}),
metaActive
:
ModelDecorationOptions
.
register
({
stickiness
:
editorCommon
.
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
inlineClassName
:
'
detected-link-active
'
,
hoverMessage
:
HOVER_MESSAGE_GENERAL_META
}),
alt
:
ModelDecorationOptions
.
register
({
stickiness
:
editorCommon
.
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
inlineClassName
:
'
detected-link
'
,
hoverMessage
:
HOVER_MESSAGE_GENERAL_ALT
}),
altActive
:
ModelDecorationOptions
.
register
({
stickiness
:
editorCommon
.
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
inlineClassName
:
'
detected-link-active
'
,
hoverMessage
:
HOVER_MESSAGE_GENERAL_ALT
}),
};
class
LinkOccurence
{
public
static
decoration
(
link
:
Link
):
editorCommon
.
IModelDeltaDecoration
{
public
static
decoration
(
link
:
Link
,
useMetaKey
:
boolean
):
editorCommon
.
IModelDeltaDecoration
{
return
{
range
:
{
startLineNumber
:
link
.
range
.
startLineNumber
,
...
...
@@ -43,24 +68,15 @@ class LinkOccurence {
endLineNumber
:
link
.
range
.
endLineNumber
,
endColumn
:
link
.
range
.
endColumn
},
options
:
LinkOccurence
.
_getOptions
(
false
)
options
:
LinkOccurence
.
_getOptions
(
useMetaKey
,
false
)
};
}
private
static
_LINK_DECORATION
=
ModelDecorationOptions
.
register
({
stickiness
:
editorCommon
.
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
inlineClassName
:
'
detected-link
'
,
hoverMessage
:
HOVER_MESSAGE_GENERAL
});
private
static
_ACTIVE_LINK_DECORATION
=
ModelDecorationOptions
.
register
({
stickiness
:
editorCommon
.
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
,
inlineClassName
:
'
detected-link-active
'
,
hoverMessage
:
HOVER_MESSAGE_GENERAL
});
private
static
_getOptions
(
isActive
:
boolean
):
ModelDecorationOptions
{
return
(
isActive
?
this
.
_ACTIVE_LINK_DECORATION
:
this
.
_LINK_DECORATION
);
private
static
_getOptions
(
useMetaKey
:
boolean
,
isActive
:
boolean
):
ModelDecorationOptions
{
if
(
useMetaKey
)
{
return
(
isActive
?
decoration
.
metaActive
:
decoration
.
meta
);
}
return
(
isActive
?
decoration
.
altActive
:
decoration
.
alt
);
}
public
decorationId
:
string
;
...
...
@@ -71,12 +87,12 @@ class LinkOccurence {
this
.
decorationId
=
decorationId
;
}
public
activate
(
changeAccessor
:
editorCommon
.
IModelDecorationsChangeAccessor
):
void
{
changeAccessor
.
changeDecorationOptions
(
this
.
decorationId
,
LinkOccurence
.
_getOptions
(
true
));
public
activate
(
changeAccessor
:
editorCommon
.
IModelDecorationsChangeAccessor
,
useMetaKey
:
boolean
):
void
{
changeAccessor
.
changeDecorationOptions
(
this
.
decorationId
,
LinkOccurence
.
_getOptions
(
useMetaKey
,
true
));
}
public
deactivate
(
changeAccessor
:
editorCommon
.
IModelDecorationsChangeAccessor
):
void
{
changeAccessor
.
changeDecorationOptions
(
this
.
decorationId
,
LinkOccurence
.
_getOptions
(
false
));
public
deactivate
(
changeAccessor
:
editorCommon
.
IModelDecorationsChangeAccessor
,
useMetaKey
:
boolean
):
void
{
changeAccessor
.
changeDecorationOptions
(
this
.
decorationId
,
LinkOccurence
.
_getOptions
(
useMetaKey
,
false
));
}
}
...
...
@@ -183,6 +199,7 @@ class LinkDetector implements editorCommon.IEditorContribution {
}
private
updateDecorations
(
links
:
Link
[]):
void
{
const
useMetaKey
=
(
this
.
editor
.
getConfiguration
().
multicursorModifier
===
'
altKey
'
);
this
.
editor
.
changeDecorations
((
changeAccessor
:
editorCommon
.
IModelDecorationsChangeAccessor
)
=>
{
var
oldDecorations
:
string
[]
=
[];
let
keys
=
Object
.
keys
(
this
.
currentOccurences
);
...
...
@@ -196,7 +213,7 @@ class LinkDetector implements editorCommon.IEditorContribution {
if
(
links
)
{
// Not sure why this is sometimes null
for
(
var
i
=
0
;
i
<
links
.
length
;
i
++
)
{
newDecorations
.
push
(
LinkOccurence
.
decoration
(
links
[
i
]));
newDecorations
.
push
(
LinkOccurence
.
decoration
(
links
[
i
]
,
useMetaKey
));
}
}
...
...
@@ -212,12 +229,13 @@ class LinkDetector implements editorCommon.IEditorContribution {
}
private
_onEditorMouseMove
(
mouseEvent
:
ClickLinkMouseEvent
,
withKey
?:
ClickLinkKeyboardEvent
):
void
{
const
useMetaKey
=
(
this
.
editor
.
getConfiguration
().
multicursorModifier
===
'
altKey
'
);
if
(
this
.
isEnabled
(
mouseEvent
,
withKey
))
{
this
.
cleanUpActiveLinkDecoration
();
// always remove previous link decoration as their can only be one
var
occurence
=
this
.
getLinkOccurence
(
mouseEvent
.
target
.
position
);
if
(
occurence
)
{
this
.
editor
.
changeDecorations
((
changeAccessor
)
=>
{
occurence
.
activate
(
changeAccessor
);
occurence
.
activate
(
changeAccessor
,
useMetaKey
);
this
.
activeLinkDecorationId
=
occurence
.
decorationId
;
});
}
...
...
@@ -227,11 +245,12 @@ class LinkDetector implements editorCommon.IEditorContribution {
}
private
cleanUpActiveLinkDecoration
():
void
{
const
useMetaKey
=
(
this
.
editor
.
getConfiguration
().
multicursorModifier
===
'
altKey
'
);
if
(
this
.
activeLinkDecorationId
)
{
var
occurence
=
this
.
currentOccurences
[
this
.
activeLinkDecorationId
];
if
(
occurence
)
{
this
.
editor
.
changeDecorations
((
changeAccessor
)
=>
{
occurence
.
deactivate
(
changeAccessor
);
occurence
.
deactivate
(
changeAccessor
,
useMetaKey
);
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录