Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
51c91003
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
51c91003
编写于
10月 10, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
💄
上级
51a7f17b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
37 deletion
+41
-37
src/vs/editor/contrib/hover/browser/modesContentHover.ts
src/vs/editor/contrib/hover/browser/modesContentHover.ts
+41
-37
未找到文件。
src/vs/editor/contrib/hover/browser/modesContentHover.ts
浏览文件 @
51c91003
...
...
@@ -35,18 +35,18 @@ class ModesContentComputer implements IHoverComputer<Hover[]> {
this
.
_range
=
null
;
}
public
setRange
(
range
:
Range
):
void
{
setRange
(
range
:
Range
):
void
{
this
.
_range
=
range
;
this
.
_result
=
[];
}
public
clearResult
():
void
{
clearResult
():
void
{
this
.
_result
=
[];
}
public
computeAsync
():
TPromise
<
Hover
[]
>
{
computeAsync
():
TPromise
<
Hover
[]
>
{
const
model
=
this
.
_editor
.
getModel
();
let
model
=
this
.
_editor
.
getModel
();
if
(
!
HoverProviderRegistry
.
has
(
model
))
{
return
TPromise
.
as
(
null
);
}
...
...
@@ -57,44 +57,47 @@ class ModesContentComputer implements IHoverComputer<Hover[]> {
));
}
public
computeSync
():
Hover
[]
{
var
result
:
Hover
[]
=
[];
var
lineNumber
=
this
.
_range
.
startLineNumber
;
computeSync
():
Hover
[]
{
const
lineNumber
=
this
.
_range
.
startLineNumber
;
if
(
lineNumber
>
this
.
_editor
.
getModel
().
getLineCount
())
{
// Illegal line number => no results
return
result
;
return
[]
;
}
var
hasHoverContent
=
(
contents
:
MarkedString
|
MarkedString
[])
=>
{
const
hasHoverContent
=
(
contents
:
MarkedString
|
MarkedString
[])
=>
{
return
contents
&&
(
!
Array
.
isArray
(
contents
)
||
(
<
MarkedString
[]
>
contents
).
length
>
0
);
};
var
lineDecorations
=
this
.
_editor
.
getLineDecorations
(
lineNumber
);
var
maxColumn
=
this
.
_editor
.
getModel
().
getLineMaxColumn
(
lineNumber
);
lineDecorations
.
forEach
((
d
)
=>
{
var
startColumn
=
(
d
.
range
.
startLineNumber
===
lineNumber
)
?
d
.
range
.
startColumn
:
1
;
var
endColumn
=
(
d
.
range
.
endLineNumber
===
lineNumber
)
?
d
.
range
.
endColumn
:
maxColumn
;
if
(
startColumn
<=
this
.
_range
.
startColumn
&&
this
.
_range
.
endColumn
<=
endColumn
&&
hasHoverContent
(
d
.
options
.
hoverMessage
))
{
var
obj
:
Hover
=
{
contents
:
[],
range
:
new
Range
(
this
.
_range
.
startLineNumber
,
startColumn
,
this
.
_range
.
startLineNumber
,
endColumn
)
};
if
(
d
.
options
.
hoverMessage
)
{
if
(
Array
.
isArray
(
d
.
options
.
hoverMessage
))
{
obj
.
contents
=
obj
.
contents
.
concat
(
<
MarkedString
[]
>
d
.
options
.
hoverMessage
);
}
else
{
obj
.
contents
.
push
(
<
MarkedString
>
d
.
options
.
hoverMessage
);
}
const
maxColumn
=
this
.
_editor
.
getModel
().
getLineMaxColumn
(
lineNumber
);
const
lineDecorations
=
this
.
_editor
.
getLineDecorations
(
lineNumber
);
const
result
=
lineDecorations
.
map
(
d
=>
{
const
startColumn
=
(
d
.
range
.
startLineNumber
===
lineNumber
)
?
d
.
range
.
startColumn
:
1
;
const
endColumn
=
(
d
.
range
.
endLineNumber
===
lineNumber
)
?
d
.
range
.
endColumn
:
maxColumn
;
if
(
startColumn
>
this
.
_range
.
startColumn
||
this
.
_range
.
endColumn
>
endColumn
||
!
hasHoverContent
(
d
.
options
.
hoverMessage
))
{
return
null
;
}
const
range
=
new
Range
(
this
.
_range
.
startLineNumber
,
startColumn
,
this
.
_range
.
startLineNumber
,
endColumn
);
let
contents
:
MarkedString
[];
if
(
d
.
options
.
hoverMessage
)
{
if
(
Array
.
isArray
(
d
.
options
.
hoverMessage
))
{
contents
=
[...
d
.
options
.
hoverMessage
];
}
else
{
contents
=
[
d
.
options
.
hoverMessage
];
}
result
.
push
(
obj
);
}
return
{
contents
,
range
};
});
return
result
;
return
result
.
filter
(
d
=>
!!
d
);
}
public
onResult
(
result
:
Hover
[],
isFromSynchronousComputation
:
boolean
):
void
{
onResult
(
result
:
Hover
[],
isFromSynchronousComputation
:
boolean
):
void
{
// Always put synchronous messages before asynchronous ones
if
(
isFromSynchronousComputation
)
{
this
.
_result
=
result
.
concat
(
this
.
_result
);
...
...
@@ -103,11 +106,11 @@ class ModesContentComputer implements IHoverComputer<Hover[]> {
}
}
public
getResult
():
Hover
[]
{
getResult
():
Hover
[]
{
return
this
.
_result
.
slice
(
0
);
}
public
getResultWithLoadingMessage
():
Hover
[]
{
getResultWithLoadingMessage
():
Hover
[]
{
return
this
.
_result
.
slice
(
0
).
concat
([
this
.
_getLoadingMessage
()]);
}
...
...
@@ -121,7 +124,8 @@ class ModesContentComputer implements IHoverComputer<Hover[]> {
export
class
ModesContentHoverWidget
extends
ContentHoverWidget
{
public
static
ID
=
'
editor.contrib.modesContentHoverWidget
'
;
static
ID
=
'
editor.contrib.modesContentHoverWidget
'
;
private
_messages
:
Hover
[];
private
_lastRange
:
Range
;
private
_computer
:
ModesContentComputer
;
...
...
@@ -149,12 +153,12 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
);
}
public
dispose
():
void
{
dispose
():
void
{
this
.
_hoverOperation
.
cancel
();
super
.
dispose
();
}
public
onModelDecorationsChanged
():
void
{
onModelDecorationsChanged
():
void
{
if
(
this
.
_isChangingDecorations
)
{
return
;
}
...
...
@@ -167,7 +171,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
}
}
public
startShowingAt
(
range
:
Range
,
focus
:
boolean
):
void
{
startShowingAt
(
range
:
Range
,
focus
:
boolean
):
void
{
if
(
this
.
_lastRange
&&
this
.
_lastRange
.
equalsRange
(
range
))
{
// We have to show the widget at the exact same range as before, so no work is needed
return
;
...
...
@@ -204,7 +208,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
this
.
_hoverOperation
.
start
();
}
public
hide
():
void
{
hide
():
void
{
this
.
_lastRange
=
null
;
this
.
_hoverOperation
.
cancel
();
super
.
hide
();
...
...
@@ -213,7 +217,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
this
.
_isChangingDecorations
=
false
;
}
public
_withResult
(
result
:
Hover
[],
complete
:
boolean
):
void
{
_withResult
(
result
:
Hover
[],
complete
:
boolean
):
void
{
this
.
_messages
=
result
;
if
(
this
.
_lastRange
&&
this
.
_messages
.
length
>
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录