Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5edb6102
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,发现更多精彩内容 >>
未验证
提交
5edb6102
编写于
12月 31, 2020
作者:
A
Alexandru Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extract all MarkdownHover computation to MarkdownHoverParticipant
上级
408539d8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
29 deletion
+42
-29
src/vs/editor/contrib/hover/markdownHoverParticipant.ts
src/vs/editor/contrib/hover/markdownHoverParticipant.ts
+34
-3
src/vs/editor/contrib/hover/markerHoverParticipant.ts
src/vs/editor/contrib/hover/markerHoverParticipant.ts
+1
-1
src/vs/editor/contrib/hover/modesContentHover.ts
src/vs/editor/contrib/hover/modesContentHover.ts
+7
-25
未找到文件。
src/vs/editor/contrib/hover/markdownHoverParticipant.ts
浏览文件 @
5edb6102
...
...
@@ -15,6 +15,10 @@ 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
{
IEditorHover
,
IEditorHoverParticipant
,
IHoverPart
}
from
'
vs/editor/contrib/hover/modesContentHover
'
;
import
{
HoverProviderRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
getHover
}
from
'
vs/editor/contrib/hover/getHover
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
const
$
=
dom
.
$
;
...
...
@@ -42,11 +46,11 @@ export class MarkdownHoverParticipant implements IEditorHoverParticipant<Markdow
@
IOpenerService
private
readonly
_openerService
:
IOpenerService
,
)
{
}
createLoadingMessage
(
range
:
Range
):
MarkdownHover
{
public
createLoadingMessage
(
range
:
Range
):
MarkdownHover
{
return
new
MarkdownHover
(
range
,
[
new
MarkdownString
().
appendText
(
nls
.
localize
(
'
modesContentHover.loading
'
,
"
Loading...
"
))]);
}
computeHoverPart
(
hoverRange
:
Range
,
model
:
ITextModel
,
decoration
:
IModelDecoration
):
MarkdownHover
|
null
{
public
computeSync
(
hoverRange
:
Range
,
model
:
ITextModel
,
decoration
:
IModelDecoration
):
MarkdownHover
|
null
{
const
hoverMessage
=
decoration
.
options
.
hoverMessage
;
if
(
!
hoverMessage
||
isEmptyMarkdownString
(
hoverMessage
))
{
return
null
;
...
...
@@ -59,7 +63,34 @@ export class MarkdownHoverParticipant implements IEditorHoverParticipant<Markdow
return
new
MarkdownHover
(
range
,
asArray
(
hoverMessage
));
}
renderHoverParts
(
hoverParts
:
MarkdownHover
[],
fragment
:
DocumentFragment
):
IDisposable
{
public
async
computeAsync
(
range
:
Range
,
token
:
CancellationToken
):
Promise
<
MarkdownHover
[]
>
{
if
(
!
this
.
_editor
.
hasModel
()
||
!
range
)
{
return
Promise
.
resolve
([]);
}
const
model
=
this
.
_editor
.
getModel
();
if
(
!
HoverProviderRegistry
.
has
(
model
))
{
return
Promise
.
resolve
([]);
}
const
hovers
=
await
getHover
(
model
,
new
Position
(
range
.
startLineNumber
,
range
.
startColumn
),
token
);
const
result
:
MarkdownHover
[]
=
[];
for
(
const
hover
of
hovers
)
{
if
(
isEmptyMarkdownString
(
hover
.
contents
))
{
continue
;
}
const
rng
=
hover
.
range
?
Range
.
lift
(
hover
.
range
)
:
range
;
result
.
push
(
new
MarkdownHover
(
rng
,
hover
.
contents
));
}
return
result
;
}
public
renderHoverParts
(
hoverParts
:
MarkdownHover
[],
fragment
:
DocumentFragment
):
IDisposable
{
const
disposables
=
new
DisposableStore
();
for
(
const
hoverPart
of
hoverParts
)
{
for
(
const
contents
of
hoverPart
.
contents
)
{
...
...
src/vs/editor/contrib/hover/markerHoverParticipant.ts
浏览文件 @
5edb6102
...
...
@@ -62,7 +62,7 @@ export class MarkerHoverParticipant implements IEditorHoverParticipant<MarkerHov
@
IOpenerService
private
readonly
_openerService
:
IOpenerService
,
)
{
}
public
compute
HoverPart
(
hoverRange
:
Range
,
model
:
ITextModel
,
decoration
:
IModelDecoration
):
MarkerHover
|
null
{
public
compute
Sync
(
hoverRange
:
Range
,
model
:
ITextModel
,
decoration
:
IModelDecoration
):
MarkerHover
|
null
{
const
marker
=
this
.
_markerDecorationsService
.
getMarker
(
model
,
decoration
);
if
(
marker
)
{
const
lineNumber
=
hoverRange
.
startLineNumber
;
...
...
src/vs/editor/contrib/hover/modesContentHover.ts
浏览文件 @
5edb6102
...
...
@@ -11,12 +11,11 @@ import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IContentW
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
ModelDecorationOptions
}
from
'
vs/editor/common/model/textModel
'
;
import
{
DocumentColorProvider
,
HoverProviderRegistry
,
IColor
,
TokenizationRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
DocumentColorProvider
,
IColor
,
TokenizationRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
getColorPresentations
}
from
'
vs/editor/contrib/colorPicker/color
'
;
import
{
ColorDetector
}
from
'
vs/editor/contrib/colorPicker/colorDetector
'
;
import
{
ColorPickerModel
}
from
'
vs/editor/contrib/colorPicker/colorPickerModel
'
;
import
{
ColorPickerWidget
}
from
'
vs/editor/contrib/colorPicker/colorPickerWidget
'
;
import
{
getHover
}
from
'
vs/editor/contrib/hover/getHover
'
;
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
'
;
...
...
@@ -44,7 +43,8 @@ export interface IEditorHover {
}
export
interface
IEditorHoverParticipant
<
T
extends
IHoverPart
=
IHoverPart
>
{
computeHoverPart
(
hoverRange
:
Range
,
model
:
ITextModel
,
decoration
:
IModelDecoration
):
T
|
null
;
computeSync
(
hoverRange
:
Range
,
model
:
ITextModel
,
decoration
:
IModelDecoration
):
T
|
null
;
computeAsync
?(
range
:
Range
,
token
:
CancellationToken
):
Promise
<
T
[]
>
;
renderHoverParts
(
hoverParts
:
T
[],
fragment
:
DocumentFragment
):
IDisposable
;
}
...
...
@@ -99,26 +99,8 @@ class ModesContentComputer implements IHoverComputer<HoverPartInfo[]> {
return
Promise
.
resolve
([]);
}
const
model
=
this
.
_editor
.
getModel
();
if
(
!
HoverProviderRegistry
.
has
(
model
))
{
return
Promise
.
resolve
([]);
}
const
hovers
=
await
getHover
(
model
,
new
Position
(
this
.
_range
.
startLineNumber
,
this
.
_range
.
startColumn
),
token
);
const
result
:
HoverPartInfo
[]
=
[];
for
(
const
hover
of
hovers
)
{
const
range
=
hover
.
range
?
Range
.
lift
(
hover
.
range
)
:
this
.
_range
;
if
(
!
range
)
{
continue
;
}
result
.
push
(
new
HoverPartInfo
(
this
.
_markdownHoverParticipant
,
false
,
new
MarkdownHover
(
range
,
hover
.
contents
)));
}
return
result
;
const
markdownHovers
=
await
this
.
_markdownHoverParticipant
.
computeAsync
(
this
.
_range
,
token
);
return
markdownHovers
.
map
(
h
=>
new
HoverPartInfo
(
this
.
_markdownHoverParticipant
,
false
,
h
));
}
public
computeSync
():
HoverPartInfo
[]
{
...
...
@@ -148,7 +130,7 @@ class ModesContentComputer implements IHoverComputer<HoverPartInfo[]> {
return
null
;
}
const
markerHover
=
this
.
_markerHoverParticipant
.
compute
HoverPart
(
hoverRange
,
model
,
d
);
const
markerHover
=
this
.
_markerHoverParticipant
.
compute
Sync
(
hoverRange
,
model
,
d
);
if
(
markerHover
)
{
return
new
HoverPartInfo
(
this
.
_markerHoverParticipant
,
true
,
markerHover
);
}
...
...
@@ -162,7 +144,7 @@ class ModesContentComputer implements IHoverComputer<HoverPartInfo[]> {
return
new
HoverPartInfo
(
null
,
true
,
new
ColorHover
(
Range
.
lift
(
range
),
color
,
colorData
.
provider
));
}
const
markdownHover
=
this
.
_markdownHoverParticipant
.
compute
HoverPart
(
hoverRange
,
model
,
d
);
const
markdownHover
=
this
.
_markdownHoverParticipant
.
compute
Sync
(
hoverRange
,
model
,
d
);
if
(
markdownHover
)
{
return
new
HoverPartInfo
(
this
.
_markdownHoverParticipant
,
true
,
markdownHover
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录