Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
408539d8
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,发现更多精彩内容 >>
未验证
提交
408539d8
编写于
12月 31, 2020
作者:
A
Alexandru Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More cleanup
上级
18982d44
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
38 deletion
+37
-38
src/vs/editor/contrib/hover/markdownHoverParticipant.ts
src/vs/editor/contrib/hover/markdownHoverParticipant.ts
+8
-8
src/vs/editor/contrib/hover/modesContentHover.ts
src/vs/editor/contrib/hover/modesContentHover.ts
+29
-30
未找到文件。
src/vs/editor/contrib/hover/markdownHoverParticipant.ts
浏览文件 @
408539d8
...
...
@@ -18,7 +18,7 @@ import { IEditorHover, IEditorHoverParticipant, IHoverPart } from 'vs/editor/con
const
$
=
dom
.
$
;
export
class
MarkdownHover
2
implements
IHoverPart
{
export
class
MarkdownHover
implements
IHoverPart
{
constructor
(
public
readonly
range
:
Range
,
...
...
@@ -26,14 +26,14 @@ export class MarkdownHover2 implements IHoverPart {
)
{
}
public
equals
(
other
:
IHoverPart
):
boolean
{
if
(
other
instanceof
MarkdownHover
2
)
{
if
(
other
instanceof
MarkdownHover
)
{
return
markedStringsEquals
(
this
.
contents
,
other
.
contents
);
}
return
false
;
}
}
export
class
MarkdownHoverParticipant
implements
IEditorHoverParticipant
<
MarkdownHover
2
>
{
export
class
MarkdownHoverParticipant
implements
IEditorHoverParticipant
<
MarkdownHover
>
{
constructor
(
private
readonly
_editor
:
ICodeEditor
,
...
...
@@ -42,11 +42,11 @@ export class MarkdownHoverParticipant implements IEditorHoverParticipant<Markdow
@
IOpenerService
private
readonly
_openerService
:
IOpenerService
,
)
{
}
createLoadingMessage
(
range
:
Range
):
MarkdownHover
2
{
return
new
MarkdownHover
2
(
range
,
[
new
MarkdownString
().
appendText
(
nls
.
localize
(
'
modesContentHover.loading
'
,
"
Loading...
"
))]);
createLoadingMessage
(
range
:
Range
):
MarkdownHover
{
return
new
MarkdownHover
(
range
,
[
new
MarkdownString
().
appendText
(
nls
.
localize
(
'
modesContentHover.loading
'
,
"
Loading...
"
))]);
}
computeHoverPart
(
hoverRange
:
Range
,
model
:
ITextModel
,
decoration
:
IModelDecoration
):
MarkdownHover
2
|
null
{
computeHoverPart
(
hoverRange
:
Range
,
model
:
ITextModel
,
decoration
:
IModelDecoration
):
MarkdownHover
|
null
{
const
hoverMessage
=
decoration
.
options
.
hoverMessage
;
if
(
!
hoverMessage
||
isEmptyMarkdownString
(
hoverMessage
))
{
return
null
;
...
...
@@ -56,10 +56,10 @@ export class MarkdownHoverParticipant implements IEditorHoverParticipant<Markdow
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
2
(
range
,
asArray
(
hoverMessage
));
return
new
MarkdownHover
(
range
,
asArray
(
hoverMessage
));
}
renderHoverParts
(
hoverParts
:
MarkdownHover
2
[],
fragment
:
DocumentFragment
):
IDisposable
{
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/modesContentHover.ts
浏览文件 @
408539d8
...
...
@@ -6,7 +6,7 @@
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
Color
,
RGBA
}
from
'
vs/base/common/color
'
;
import
{
IDisposable
,
DisposableStore
,
combinedDisposable
,
MutableDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
DisposableStore
,
combinedDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ContentWidgetPositionPreference
,
ICodeEditor
,
IContentWidget
,
IContentWidgetPosition
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
...
...
@@ -31,7 +31,7 @@ import { KeyCode } from 'vs/base/common/keyCodes';
import
{
HoverWidget
}
from
'
vs/base/browser/ui/hover/hoverWidget
'
;
import
{
MarkerHover
,
MarkerHoverParticipant
}
from
'
vs/editor/contrib/hover/markerHoverParticipant
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
MarkdownHover
2
,
MarkdownHoverParticipant
}
from
'
vs/editor/contrib/hover/markdownHoverParticipant
'
;
import
{
MarkdownHover
,
MarkdownHoverParticipant
}
from
'
vs/editor/contrib/hover/markdownHoverParticipant
'
;
export
interface
IHoverPart
{
readonly
range
:
Range
;
...
...
@@ -116,7 +116,7 @@ class ModesContentComputer implements IHoverComputer<HoverPartInfo[]> {
if
(
!
range
)
{
continue
;
}
result
.
push
(
new
HoverPartInfo
(
this
.
_markdownHoverParticipant
,
false
,
new
MarkdownHover
2
(
range
,
hover
.
contents
)));
result
.
push
(
new
HoverPartInfo
(
this
.
_markdownHoverParticipant
,
false
,
new
MarkdownHover
(
range
,
hover
.
contents
)));
}
return
result
;
}
...
...
@@ -212,14 +212,14 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
private
readonly
_hover
:
HoverWidget
;
private
readonly
_id
:
string
;
private
_editor
:
ICodeEditor
;
private
readonly
_editor
:
ICodeEditor
;
private
_isVisible
:
boolean
;
private
_showAtPosition
:
Position
|
null
;
private
_showAtRange
:
Range
|
null
;
private
_stoleFocus
:
boolean
;
// IContentWidget.allowEditorOverflow
public
allowEditorOverflow
=
true
;
public
readonly
allowEditorOverflow
=
true
;
private
_messages
:
HoverPartInfo
[];
private
_lastRange
:
Range
|
null
;
...
...
@@ -229,17 +229,7 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
private
_isChangingDecorations
:
boolean
;
private
_shouldFocus
:
boolean
;
private
_colorPicker
:
ColorPickerWidget
|
null
;
private
readonly
renderDisposable
=
this
.
_register
(
new
MutableDisposable
<
IDisposable
>
());
private
get
isVisible
():
boolean
{
return
this
.
_isVisible
;
}
private
set
isVisible
(
value
:
boolean
)
{
this
.
_isVisible
=
value
;
this
.
_hover
.
containerDomNode
.
classList
.
toggle
(
'
hidden
'
,
!
this
.
_isVisible
);
}
private
_renderDisposable
:
IDisposable
|
null
;
constructor
(
editor
:
ICodeEditor
,
...
...
@@ -257,6 +247,7 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
this
.
_editor
=
editor
;
this
.
_isVisible
=
false
;
this
.
_stoleFocus
=
false
;
this
.
_renderDisposable
=
null
;
this
.
onkeydown
(
this
.
_hover
.
containerDomNode
,
(
e
:
IKeyboardEvent
)
=>
{
if
(
e
.
equals
(
KeyCode
.
Escape
))
{
...
...
@@ -306,7 +297,7 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
this
.
_hoverOperation
.
setHoverTime
(
this
.
_editor
.
getOption
(
EditorOption
.
hover
).
delay
);
}));
this
.
_register
(
TokenizationRegistry
.
onDidChange
(()
=>
{
if
(
this
.
isVisible
&&
this
.
_lastRange
&&
this
.
_messages
.
length
>
0
)
{
if
(
this
.
_
isVisible
&&
this
.
_lastRange
&&
this
.
_messages
.
length
>
0
)
{
this
.
_messages
=
this
.
_messages
.
map
(
msg
=>
{
// If a color hover is visible, we need to update the message that
// created it so that the color matches the last chosen color
...
...
@@ -349,7 +340,8 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
this
.
_showAtPosition
=
position
;
this
.
_showAtRange
=
range
;
this
.
_hoverVisibleKey
.
set
(
true
);
this
.
isVisible
=
true
;
this
.
_isVisible
=
true
;
this
.
_hover
.
containerDomNode
.
classList
.
toggle
(
'
hidden
'
,
!
this
.
_isVisible
);
this
.
_editor
.
layoutContentWidget
(
this
);
// Simply force a synchronous render on the editor
...
...
@@ -362,7 +354,7 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
}
public
getPosition
():
IContentWidgetPosition
|
null
{
if
(
this
.
isVisible
)
{
if
(
this
.
_
isVisible
)
{
return
{
position
:
this
.
_showAtPosition
,
range
:
this
.
_showAtRange
,
...
...
@@ -403,7 +395,7 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
if
(
this
.
_isChangingDecorations
)
{
return
;
}
if
(
this
.
isVisible
)
{
if
(
this
.
_
isVisible
)
{
// The decorations have changed and the hover is visible,
// we need to recompute the displayed text
this
.
_hoverOperation
.
cancel
();
...
...
@@ -423,7 +415,7 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
this
.
_hoverOperation
.
cancel
();
if
(
this
.
isVisible
)
{
if
(
this
.
_
isVisible
)
{
// The range might have changed, but the hover is visible
// Instead of hiding it completely, filter out messages that are still in the new range and
// kick off a new computation
...
...
@@ -459,14 +451,15 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
this
.
_lastRange
=
null
;
this
.
_hoverOperation
.
cancel
();
if
(
this
.
isVisible
)
{
if
(
this
.
_
isVisible
)
{
setTimeout
(()
=>
{
// Give commands a chance to see the key
if
(
!
this
.
isVisible
)
{
if
(
!
this
.
_
isVisible
)
{
this
.
_hoverVisibleKey
.
set
(
false
);
}
},
0
);
this
.
isVisible
=
false
;
this
.
_isVisible
=
false
;
this
.
_hover
.
containerDomNode
.
classList
.
toggle
(
'
hidden
'
,
!
this
.
_isVisible
);
this
.
_editor
.
layoutContentWidget
(
this
);
if
(
this
.
_stoleFocus
)
{
...
...
@@ -477,7 +470,10 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
this
.
_isChangingDecorations
=
true
;
this
.
_highlightDecorations
=
this
.
_editor
.
deltaDecorations
(
this
.
_highlightDecorations
,
[]);
this
.
_isChangingDecorations
=
false
;
this
.
renderDisposable
.
clear
();
if
(
this
.
_renderDisposable
)
{
this
.
_renderDisposable
.
dispose
();
this
.
_renderDisposable
=
null
;
}
this
.
_colorPicker
=
null
;
}
...
...
@@ -503,7 +499,10 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
}
private
_renderMessages
(
renderRange
:
Range
,
messages
:
HoverPartInfo
[]):
void
{
this
.
renderDisposable
.
dispose
();
if
(
this
.
_renderDisposable
)
{
this
.
_renderDisposable
.
dispose
();
this
.
_renderDisposable
=
null
;
}
this
.
_colorPicker
=
null
;
// update column from which to show
...
...
@@ -514,7 +513,7 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
let
containColorPicker
=
false
;
const
disposables
=
new
DisposableStore
();
const
markerMessages
:
MarkerHover
[]
=
[];
const
markdownParts
:
MarkdownHover
2
[]
=
[];
const
markdownParts
:
MarkdownHover
[]
=
[];
messages
.
forEach
((
_msg
)
=>
{
const
msg
=
_msg
.
data
;
if
(
!
msg
.
range
)
{
...
...
@@ -607,13 +606,13 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
this
.
_updateContents
(
fragment
);
this
.
_colorPicker
.
layout
();
this
.
renderDisposable
.
valu
e
=
combinedDisposable
(
colorListener
,
colorChangeListener
,
widget
,
disposables
);
this
.
_renderDisposabl
e
=
combinedDisposable
(
colorListener
,
colorChangeListener
,
widget
,
disposables
);
});
}
else
{
if
(
msg
instanceof
MarkerHover
)
{
markerMessages
.
push
(
msg
);
}
else
{
if
(
msg
instanceof
MarkdownHover
2
)
{
if
(
msg
instanceof
MarkdownHover
)
{
markdownParts
.
push
(
msg
);
}
}
...
...
@@ -628,7 +627,7 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget {
disposables
.
add
(
this
.
_markerHoverParticipant
.
renderHoverParts
(
markerMessages
,
fragment
));
}
this
.
renderDisposable
.
valu
e
=
disposables
;
this
.
_renderDisposabl
e
=
disposables
;
// show
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录