Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4e7e2123
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,发现更多精彩内容 >>
未验证
提交
4e7e2123
编写于
12月 31, 2020
作者:
A
Alexandru Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Have `computeSync` return an array of results
上级
5edb6102
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
65 addition
and
47 deletion
+65
-47
src/vs/editor/contrib/hover/markdownHoverParticipant.ts
src/vs/editor/contrib/hover/markdownHoverParticipant.ts
+21
-9
src/vs/editor/contrib/hover/markerHoverParticipant.ts
src/vs/editor/contrib/hover/markerHoverParticipant.ts
+22
-10
src/vs/editor/contrib/hover/modesContentHover.ts
src/vs/editor/contrib/hover/modesContentHover.ts
+22
-28
未找到文件。
src/vs/editor/contrib/hover/markdownHoverParticipant.ts
浏览文件 @
4e7e2123
...
...
@@ -13,7 +13,7 @@ import { MarkdownRenderer } from 'vs/editor/browser/core/markdownRenderer';
import
{
asArray
}
from
'
vs/base/common/arrays
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IModelDecoration
,
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
IModelDecoration
}
from
'
vs/editor/common/model
'
;
import
{
IEditorHover
,
IEditorHoverParticipant
,
IHoverPart
}
from
'
vs/editor/contrib/hover/modesContentHover
'
;
import
{
HoverProviderRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
getHover
}
from
'
vs/editor/contrib/hover/getHover
'
;
...
...
@@ -50,17 +50,29 @@ export class MarkdownHoverParticipant implements IEditorHoverParticipant<Markdow
return
new
MarkdownHover
(
range
,
[
new
MarkdownString
().
appendText
(
nls
.
localize
(
'
modesContentHover.loading
'
,
"
Loading...
"
))]);
}
public
computeSync
(
hoverRange
:
Range
,
model
:
ITextModel
,
decoration
:
IModelDecoration
):
MarkdownHover
|
null
{
const
hoverMessage
=
decoration
.
options
.
hoverMessage
;
if
(
!
hoverMessage
||
isEmptyMarkdownString
(
hoverMessage
))
{
return
null
;
public
computeSync
(
hoverRange
:
Range
,
lineDecorations
:
IModelDecoration
[]):
MarkdownHover
[]
{
if
(
!
this
.
_editor
.
hasModel
())
{
return
[];
}
const
model
=
this
.
_editor
.
getModel
();
const
lineNumber
=
hoverRange
.
startLineNumber
;
const
maxColumn
=
model
.
getLineMaxColumn
(
lineNumber
);
const
startColumn
=
(
decoration
.
range
.
startLineNumber
===
lineNumber
)
?
decoration
.
range
.
startColumn
:
1
;
const
endColumn
=
(
decoration
.
range
.
endLineNumber
===
lineNumber
)
?
decoration
.
range
.
endColumn
:
maxColumn
;
const
range
=
new
Range
(
hoverRange
.
startLineNumber
,
startColumn
,
hoverRange
.
startLineNumber
,
endColumn
);
return
new
MarkdownHover
(
range
,
asArray
(
hoverMessage
));
const
result
:
MarkdownHover
[]
=
[];
for
(
const
d
of
lineDecorations
)
{
const
startColumn
=
(
d
.
range
.
startLineNumber
===
lineNumber
)
?
d
.
range
.
startColumn
:
1
;
const
endColumn
=
(
d
.
range
.
endLineNumber
===
lineNumber
)
?
d
.
range
.
endColumn
:
maxColumn
;
const
hoverMessage
=
d
.
options
.
hoverMessage
;
if
(
!
hoverMessage
||
isEmptyMarkdownString
(
hoverMessage
))
{
continue
;
}
const
range
=
new
Range
(
hoverRange
.
startLineNumber
,
startColumn
,
hoverRange
.
startLineNumber
,
endColumn
);
result
.
push
(
new
MarkdownHover
(
range
,
asArray
(
hoverMessage
)));
}
return
result
;
}
public
async
computeAsync
(
range
:
Range
,
token
:
CancellationToken
):
Promise
<
MarkdownHover
[]
>
{
...
...
src/vs/editor/contrib/hover/markerHoverParticipant.ts
浏览文件 @
4e7e2123
...
...
@@ -21,7 +21,7 @@ import { CancelablePromise, createCancelablePromise, disposableTimeout } from 'v
import
{
getCodeActions
,
CodeActionSet
}
from
'
vs/editor/contrib/codeAction/codeAction
'
;
import
{
QuickFixAction
,
QuickFixController
}
from
'
vs/editor/contrib/codeAction/codeActionCommands
'
;
import
{
CodeActionKind
,
CodeActionTrigger
}
from
'
vs/editor/contrib/codeAction/types
'
;
import
{
IModelDecoration
,
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
IModelDecoration
}
from
'
vs/editor/common/model
'
;
import
{
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
Progress
}
from
'
vs/platform/progress/common/progress
'
;
import
{
ITextEditorOptions
}
from
'
vs/platform/editor/common/editor
'
;
...
...
@@ -62,17 +62,29 @@ export class MarkerHoverParticipant implements IEditorHoverParticipant<MarkerHov
@
IOpenerService
private
readonly
_openerService
:
IOpenerService
,
)
{
}
public
computeSync
(
hoverRange
:
Range
,
model
:
ITextModel
,
decoration
:
IModelDecoration
):
MarkerHover
|
null
{
const
marker
=
this
.
_markerDecorationsService
.
getMarker
(
model
,
decoration
);
if
(
marker
)
{
const
lineNumber
=
hoverRange
.
startLineNumber
;
const
maxColumn
=
model
.
getLineMaxColumn
(
lineNumber
);
const
startColumn
=
(
decoration
.
range
.
startLineNumber
===
lineNumber
)
?
decoration
.
range
.
startColumn
:
1
;
const
endColumn
=
(
decoration
.
range
.
endLineNumber
===
lineNumber
)
?
decoration
.
range
.
endColumn
:
maxColumn
;
public
computeSync
(
hoverRange
:
Range
,
lineDecorations
:
IModelDecoration
[]):
MarkerHover
[]
{
if
(
!
this
.
_editor
.
hasModel
())
{
return
[];
}
const
model
=
this
.
_editor
.
getModel
();
const
lineNumber
=
hoverRange
.
startLineNumber
;
const
maxColumn
=
model
.
getLineMaxColumn
(
lineNumber
);
const
result
:
MarkerHover
[]
=
[];
for
(
const
d
of
lineDecorations
)
{
const
startColumn
=
(
d
.
range
.
startLineNumber
===
lineNumber
)
?
d
.
range
.
startColumn
:
1
;
const
endColumn
=
(
d
.
range
.
endLineNumber
===
lineNumber
)
?
d
.
range
.
endColumn
:
maxColumn
;
const
marker
=
this
.
_markerDecorationsService
.
getMarker
(
model
,
d
);
if
(
!
marker
)
{
continue
;
}
const
range
=
new
Range
(
hoverRange
.
startLineNumber
,
startColumn
,
hoverRange
.
startLineNumber
,
endColumn
);
re
turn
new
MarkerHover
(
range
,
marker
);
re
sult
.
push
(
new
MarkerHover
(
range
,
marker
)
);
}
return
null
;
return
result
;
}
public
renderHoverParts
(
hoverParts
:
MarkerHover
[],
fragment
:
DocumentFragment
):
IDisposable
{
...
...
src/vs/editor/contrib/hover/modesContentHover.ts
浏览文件 @
4e7e2123
...
...
@@ -19,7 +19,7 @@ import { ColorPickerWidget } from 'vs/editor/contrib/colorPicker/colorPickerWidg
import
{
HoverOperation
,
HoverStartMode
,
IHoverComputer
}
from
'
vs/editor/contrib/hover/hoverOperation
'
;
import
{
IThemeService
,
registerThemingParticipant
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
coalesce
}
from
'
vs/base/common/arrays
'
;
import
{
IIdentifiedSingleEditOperation
,
IModelDecoration
,
ITextModel
,
TrackedRangeStickiness
}
from
'
vs/editor/common/model
'
;
import
{
IIdentifiedSingleEditOperation
,
IModelDecoration
,
TrackedRangeStickiness
}
from
'
vs/editor/common/model
'
;
import
{
ConfigurationChangedEvent
,
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
Constants
}
from
'
vs/base/common/uint
'
;
import
{
textLinkForeground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
...
...
@@ -43,7 +43,7 @@ export interface IEditorHover {
}
export
interface
IEditorHoverParticipant
<
T
extends
IHoverPart
=
IHoverPart
>
{
computeSync
(
hoverRange
:
Range
,
model
:
ITextModel
,
decoration
:
IModelDecoration
):
T
|
null
;
computeSync
(
hoverRange
:
Range
,
lineDecorations
:
IModelDecoration
[]):
T
[]
;
computeAsync
?(
range
:
Range
,
token
:
CancellationToken
):
Promise
<
T
[]
>
;
renderHoverParts
(
hoverParts
:
T
[],
fragment
:
DocumentFragment
):
IDisposable
;
}
...
...
@@ -109,48 +109,42 @@ class ModesContentComputer implements IHoverComputer<HoverPartInfo[]> {
}
const
model
=
this
.
_editor
.
getModel
();
const
lineNumber
=
this
.
_range
.
startLineNumber
;
const
hoverRange
=
this
.
_range
;
const
lineNumber
=
hoverRange
.
startLineNumber
;
if
(
lineNumber
>
this
.
_editor
.
getModel
().
getLineCount
())
{
// Illegal line number => no results
return
[];
}
const
colorDetector
=
ColorDetector
.
get
(
this
.
_editor
);
const
maxColumn
=
model
.
getLineMaxColumn
(
lineNumber
);
const
lineDecorations
=
this
.
_editor
.
getLineDecorations
(
lineNumber
);
let
didFindColor
=
false
;
const
hoverRange
=
this
.
_range
;
const
result
=
lineDecorations
.
map
((
d
):
HoverPartInfo
|
null
=>
{
const
lineDecorations
=
this
.
_editor
.
getLineDecorations
(
lineNumber
).
filter
((
d
)
=>
{
const
startColumn
=
(
d
.
range
.
startLineNumber
===
lineNumber
)
?
d
.
range
.
startColumn
:
1
;
const
endColumn
=
(
d
.
range
.
endLineNumber
===
lineNumber
)
?
d
.
range
.
endColumn
:
maxColumn
;
if
(
startColumn
>
hoverRange
.
startColumn
||
hoverRange
.
endColumn
>
endColumn
)
{
return
null
;
return
false
;
}
return
true
;
});
const
markerHover
=
this
.
_markerHoverParticipant
.
computeSync
(
hoverRange
,
model
,
d
);
if
(
markerHover
)
{
return
new
HoverPartInfo
(
this
.
_markerHoverParticipant
,
true
,
markerHover
);
}
let
result
:
HoverPartInfo
[]
=
[];
const
colorData
=
colorDetector
.
getColorData
(
d
.
range
.
getStartPosition
());
const
markdownHovers
=
this
.
_markdownHoverParticipant
.
computeSync
(
this
.
_range
,
lineDecorations
);
result
=
result
.
concat
(
markdownHovers
.
map
(
h
=>
new
HoverPartInfo
(
this
.
_markdownHoverParticipant
,
true
,
h
)));
if
(
!
didFindColor
&&
colorData
)
{
didFindColor
=
true
;
const
markerHovers
=
this
.
_markerHoverParticipant
.
computeSync
(
this
.
_range
,
lineDecorations
);
result
=
result
.
concat
(
markerHovers
.
map
(
h
=>
new
HoverPartInfo
(
this
.
_markerHoverParticipant
,
true
,
h
)))
;
const
{
color
,
range
}
=
colorData
.
colorInfo
;
return
new
HoverPartInfo
(
null
,
true
,
new
ColorHover
(
Range
.
lift
(
range
),
color
,
colorData
.
provider
));
}
const
colorDetector
=
ColorDetector
.
get
(
this
.
_editor
);
const
markdownHover
=
this
.
_markdownHoverParticipant
.
computeSync
(
hoverRange
,
model
,
d
);
if
(
markdownHover
)
{
return
new
HoverPartInfo
(
this
.
_markdownHoverParticipant
,
true
,
markdownHover
);
for
(
const
d
of
lineDecorations
)
{
const
colorData
=
colorDetector
.
getColorData
(
d
.
range
.
getStartPosition
());
if
(
colorData
)
{
const
{
color
,
range
}
=
colorData
.
colorInfo
;
result
.
push
(
new
HoverPartInfo
(
null
,
true
,
new
ColorHover
(
Range
.
lift
(
range
),
color
,
colorData
.
provider
)));
break
;
}
return
null
;
});
}
return
coalesce
(
result
);
}
...
...
@@ -185,7 +179,7 @@ class ModesContentComputer implements IHoverComputer<HoverPartInfo[]> {
}
}
export
class
ModesContentHoverWidget
extends
Widget
implements
IContentWidget
{
export
class
ModesContentHoverWidget
extends
Widget
implements
IContentWidget
,
IEditorHover
{
static
readonly
ID
=
'
editor.contrib.modesContentHoverWidget
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录