Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f3b8d15b
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,发现更多精彩内容 >>
提交
f3b8d15b
编写于
5月 23, 2019
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add DocumentLink.tooltip api proposal
For #72824
上级
5b9869eb
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
62 addition
and
13 deletion
+62
-13
extensions/markdown-language-features/src/features/documentLinkProvider.ts
...wn-language-features/src/features/documentLinkProvider.ts
+18
-10
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+1
-0
src/vs/editor/contrib/links/getLinks.ts
src/vs/editor/contrib/links/getLinks.ts
+6
-1
src/vs/editor/contrib/links/links.ts
src/vs/editor/contrib/links/links.ts
+17
-0
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+1
-0
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+10
-0
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+1
-0
src/vs/workbench/api/common/extHostTypeConverters.ts
src/vs/workbench/api/common/extHostTypeConverters.ts
+2
-1
src/vs/workbench/api/common/extHostTypes.ts
src/vs/workbench/api/common/extHostTypes.ts
+2
-0
src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts
...test/electron-browser/api/extHostLanguageFeatures.test.ts
+4
-1
未找到文件。
extensions/markdown-language-features/src/features/documentLinkProvider.ts
浏览文件 @
f3b8d15b
...
...
@@ -5,17 +5,20 @@
import
*
as
path
from
'
path
'
;
import
*
as
vscode
from
'
vscode
'
;
import
*
as
nls
from
'
vscode-nls
'
;
import
{
OpenDocumentLinkCommand
}
from
'
../commands/openDocumentLink
'
;
import
{
getUriForLinkWithKnownExternalScheme
}
from
'
../util/links
'
;
function
normalizeLink
(
const
localize
=
nls
.
loadMessageBundle
();
function
parseLink
(
document
:
vscode
.
TextDocument
,
link
:
string
,
base
:
string
):
vscode
.
Uri
{
):
{
uri
:
vscode
.
Uri
,
tooltip
?:
string
}
{
const
externalSchemeUri
=
getUriForLinkWithKnownExternalScheme
(
link
);
if
(
externalSchemeUri
)
{
return
externalSchemeUri
;
return
{
uri
:
externalSchemeUri
}
;
}
// Assume it must be an relative or absolute file path
...
...
@@ -34,7 +37,10 @@ function normalizeLink(
resourcePath
=
base
?
path
.
join
(
base
,
tempUri
.
path
)
:
tempUri
.
path
;
}
return
OpenDocumentLinkCommand
.
createCommandUri
(
resourcePath
,
tempUri
.
fragment
);
return
{
uri
:
OpenDocumentLinkCommand
.
createCommandUri
(
resourcePath
,
tempUri
.
fragment
),
tooltip
:
localize
(
'
documentLink.tooltip
'
,
'
follow link
'
)
};
}
function
matchAll
(
...
...
@@ -61,9 +67,12 @@ function extractDocumentLink(
const
linkStart
=
document
.
positionAt
(
offset
);
const
linkEnd
=
document
.
positionAt
(
offset
+
link
.
length
);
try
{
return
new
vscode
.
DocumentLink
(
const
{
uri
,
tooltip
}
=
parseLink
(
document
,
link
,
base
);
const
documentLink
=
new
vscode
.
DocumentLink
(
new
vscode
.
Range
(
linkStart
,
linkEnd
),
normalizeLink
(
document
,
link
,
base
));
uri
);
documentLink
.
tooltip
=
tooltip
;
return
documentLink
;
}
catch
(
e
)
{
return
undefined
;
}
...
...
@@ -144,11 +153,10 @@ export default class LinkProvider implements vscode.DocumentLinkProvider {
}
}
for
(
const
definition
of
Array
.
from
(
definitions
.
values
()
))
{
for
(
const
definition
of
definitions
.
values
(
))
{
try
{
results
.
push
(
new
vscode
.
DocumentLink
(
definition
.
linkRange
,
normalizeLink
(
document
,
definition
.
link
,
base
)));
const
{
uri
}
=
parseLink
(
document
,
definition
.
link
,
base
);
results
.
push
(
new
vscode
.
DocumentLink
(
definition
.
linkRange
,
uri
));
}
catch
(
e
)
{
// noop
}
...
...
src/vs/editor/common/modes.ts
浏览文件 @
f3b8d15b
...
...
@@ -1000,6 +1000,7 @@ export interface IInplaceReplaceSupportResult {
export
interface
ILink
{
range
:
IRange
;
url
?:
URI
|
string
;
tooltip
?:
string
;
}
export
interface
ILinksList
{
...
...
src/vs/editor/contrib/links/getLinks.ts
浏览文件 @
f3b8d15b
...
...
@@ -27,7 +27,8 @@ export class Link implements ILink {
toJSON
():
ILink
{
return
{
range
:
this
.
range
,
url
:
this
.
url
url
:
this
.
url
,
tooltip
:
this
.
tooltip
};
}
...
...
@@ -39,6 +40,10 @@ export class Link implements ILink {
return
this
.
_link
.
url
;
}
get
tooltip
():
string
|
undefined
{
return
this
.
_link
.
tooltip
;
}
resolve
(
token
:
CancellationToken
):
Promise
<
URI
>
{
if
(
this
.
_link
.
url
)
{
try
{
...
...
src/vs/editor/contrib/links/links.ts
浏览文件 @
f3b8d15b
...
...
@@ -111,6 +111,23 @@ class LinkOccurrence {
}
private
static
_getOptions
(
link
:
Link
,
useMetaKey
:
boolean
,
isActive
:
boolean
):
ModelDecorationOptions
{
const
options
=
{
...
this
.
_getBaseOptions
(
link
,
useMetaKey
,
isActive
)
};
if
(
typeof
link
.
tooltip
===
'
string
'
)
{
const
message
=
new
MarkdownString
().
appendText
(
platform
.
isMacintosh
?
useMetaKey
?
nls
.
localize
(
'
links.custom.mac
'
,
"
Cmd + click to {0}
"
,
link
.
tooltip
)
:
nls
.
localize
(
'
links.custom.mac.al
'
,
"
Option + click to {0}
"
,
link
.
tooltip
)
:
useMetaKey
?
nls
.
localize
(
'
links.custom
'
,
"
Ctrl + click to {0}
"
,
link
.
tooltip
)
:
nls
.
localize
(
'
links.custom.al
'
,
"
Alt + click to {0}
"
,
link
.
tooltip
)
);
options
.
hoverMessage
=
message
;
}
return
options
;
}
private
static
_getBaseOptions
(
link
:
Link
,
useMetaKey
:
boolean
,
isActive
:
boolean
):
ModelDecorationOptions
{
if
(
link
.
url
&&
/^command:/i
.
test
(
link
.
url
.
toString
()))
{
if
(
useMetaKey
)
{
return
(
isActive
?
decoration
.
metaCommandActive
:
decoration
.
metaCommand
);
...
...
src/vs/monaco.d.ts
浏览文件 @
f3b8d15b
...
...
@@ -5254,6 +5254,7 @@ declare namespace monaco.languages {
export
interface
ILink
{
range
:
IRange
;
url
?:
Uri
|
string
;
tooltip
?:
string
;
}
export
interface
ILinksList
{
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
f3b8d15b
...
...
@@ -1426,4 +1426,14 @@ declare module 'vscode' {
//#endregion
//#region DocumentLink tooltip mjbvz
interface
DocumentLink
{
/**
* The tooltip text when you hover over this link.
*/
tooltip
?:
string
;
}
// #endregion
}
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
f3b8d15b
...
...
@@ -996,6 +996,7 @@ export interface LinkDto {
cacheId
?:
ChainedCacheId
;
range
:
IRange
;
url
?:
string
|
UriComponents
;
tooltip
?:
string
;
}
export
interface
CodeLensDto
extends
ObjectIdentifier
{
...
...
src/vs/workbench/api/common/extHostTypeConverters.ts
浏览文件 @
f3b8d15b
...
...
@@ -808,7 +808,8 @@ export namespace DocumentLink {
export
function
from
(
link
:
vscode
.
DocumentLink
):
modes
.
ILink
{
return
{
range
:
Range
.
from
(
link
.
range
),
url
:
link
.
target
url
:
link
.
target
,
tooltip
:
link
.
tooltip
};
}
...
...
src/vs/workbench/api/common/extHostTypes.ts
浏览文件 @
f3b8d15b
...
...
@@ -1440,6 +1440,8 @@ export class DocumentLink {
target
?:
URI
;
tooltip
?:
string
;
constructor
(
range
:
Range
,
target
:
URI
|
undefined
)
{
if
(
target
&&
!
(
target
instanceof
URI
))
{
throw
illegalArgument
(
'
target
'
);
...
...
src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts
浏览文件 @
f3b8d15b
...
...
@@ -1041,7 +1041,9 @@ suite('ExtHostLanguageFeatures', function () {
disposables
.
push
(
extHost
.
registerDocumentLinkProvider
(
defaultExtension
,
defaultSelector
,
new
class
implements
vscode
.
DocumentLinkProvider
{
provideDocumentLinks
()
{
return
[
new
types
.
DocumentLink
(
new
types
.
Range
(
0
,
0
,
1
,
1
),
URI
.
parse
(
'
foo:bar#3
'
))];
const
link
=
new
types
.
DocumentLink
(
new
types
.
Range
(
0
,
0
,
1
,
1
),
URI
.
parse
(
'
foo:bar#3
'
));
link
.
tooltip
=
'
tooltip
'
;
return
[
link
];
}
}));
...
...
@@ -1051,6 +1053,7 @@ suite('ExtHostLanguageFeatures', function () {
let
[
first
]
=
links
;
assert
.
equal
(
first
.
url
,
'
foo:bar#3
'
);
assert
.
deepEqual
(
first
.
range
,
{
startLineNumber
:
1
,
startColumn
:
1
,
endLineNumber
:
2
,
endColumn
:
2
});
assert
.
equal
(
first
.
tooltip
,
'
tooltip
'
);
});
test
(
'
Links, evil provider
'
,
async
()
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录