Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
825e63f8
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,发现更多精彩内容 >>
提交
825e63f8
编写于
9月 21, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tweaks to content widgets renderings (#34716)
上级
0bb671fd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
74 addition
and
29 deletion
+74
-29
src/vs/editor/browser/view/viewImpl.ts
src/vs/editor/browser/view/viewImpl.ts
+5
-0
src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts
...editor/browser/viewParts/contentWidgets/contentWidgets.ts
+69
-29
未找到文件。
src/vs/editor/browser/view/viewImpl.ts
浏览文件 @
825e63f8
...
...
@@ -420,6 +420,11 @@ export class View extends ViewEventHandler {
this
.
_context
.
model
);
if
(
this
.
contentWidgets
.
shouldRender
())
{
// Give the content widgets a chance to set their max width before a possible synchronous layout
this
.
contentWidgets
.
onBeforeRender
(
viewportData
);
}
if
(
this
.
viewLines
.
shouldRender
())
{
this
.
viewLines
.
renderText
(
viewportData
);
this
.
viewLines
.
onDidRender
();
...
...
src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts
浏览文件 @
825e63f8
...
...
@@ -13,6 +13,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext';
import
{
RenderingContext
,
RestrictedRenderingContext
}
from
'
vs/editor/common/view/renderingContext
'
;
import
{
Position
,
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
*
as
viewEvents
from
'
vs/editor/common/view/viewEvents
'
;
import
{
ViewportData
}
from
'
vs/editor/common/viewLayout/viewLinesViewportData
'
;
class
Coordinate
{
_coordinateBrand
:
void
;
...
...
@@ -73,6 +74,14 @@ export class ViewContentWidgets extends ViewPart {
public
onFlushed
(
e
:
viewEvents
.
ViewFlushedEvent
):
boolean
{
return
true
;
}
public
onLineMappingChanged
(
e
:
viewEvents
.
ViewLineMappingChangedEvent
):
boolean
{
let
keys
=
Object
.
keys
(
this
.
_widgets
);
for
(
let
i
=
0
,
len
=
keys
.
length
;
i
<
len
;
i
++
)
{
const
widgetId
=
keys
[
i
];
this
.
_widgets
[
widgetId
].
onLineMappingChanged
(
e
);
}
return
true
;
}
public
onLinesChanged
(
e
:
viewEvents
.
ViewLinesChangedEvent
):
boolean
{
return
true
;
}
...
...
@@ -132,6 +141,14 @@ export class ViewContentWidgets extends ViewPart {
return
false
;
}
public
onBeforeRender
(
viewportData
:
ViewportData
):
void
{
let
keys
=
Object
.
keys
(
this
.
_widgets
);
for
(
let
i
=
0
,
len
=
keys
.
length
;
i
<
len
;
i
++
)
{
const
widgetId
=
keys
[
i
];
this
.
_widgets
[
widgetId
].
onBeforeRender
(
viewportData
);
}
}
public
prepareRender
(
ctx
:
RenderingContext
):
void
{
let
keys
=
Object
.
keys
(
this
.
_widgets
);
for
(
let
i
=
0
,
len
=
keys
.
length
;
i
<
len
;
i
++
)
{
...
...
@@ -173,11 +190,13 @@ class Widget {
private
_lineHeight
:
number
;
private
_position
:
IPosition
;
private
_viewPosition
:
Position
;
private
_preference
:
ContentWidgetPositionPreference
[];
private
_cachedDomNodeClientWidth
:
number
;
private
_cachedDomNodeClientHeight
:
number
;
private
_maxWidth
:
number
;
private
_isVisible
:
boolean
;
private
_renderData
:
Coordinate
;
constructor
(
context
:
ViewContext
,
viewDomNode
:
FastDomNode
<
HTMLElement
>
,
actual
:
IContentWidget
)
{
...
...
@@ -195,7 +214,7 @@ class Widget {
this
.
_contentLeft
=
this
.
_context
.
configuration
.
editor
.
layoutInfo
.
contentLeft
;
this
.
_lineHeight
=
this
.
_context
.
configuration
.
editor
.
lineHeight
;
this
.
_
position
=
null
;
this
.
_
setPosition
(
null
)
;
this
.
_preference
=
null
;
this
.
_cachedDomNodeClientWidth
=
-
1
;
this
.
_cachedDomNodeClientHeight
=
-
1
;
...
...
@@ -206,6 +225,7 @@ class Widget {
this
.
domNode
.
setPosition
((
this
.
_fixedOverflowWidgets
&&
this
.
allowEditorOverflow
)
?
'
fixed
'
:
'
absolute
'
);
this
.
domNode
.
setVisibility
(
'
hidden
'
);
this
.
domNode
.
setAttribute
(
'
widgetId
'
,
this
.
id
);
this
.
domNode
.
setMaxWidth
(
this
.
_maxWidth
);
}
public
onConfigurationChanged
(
e
:
viewEvents
.
ViewConfigurationChangedEvent
):
void
{
...
...
@@ -219,6 +239,23 @@ class Widget {
}
}
public
onLineMappingChanged
(
e
:
viewEvents
.
ViewLineMappingChangedEvent
):
void
{
this
.
_setPosition
(
this
.
_position
);
}
private
_setPosition
(
position
:
IPosition
):
void
{
this
.
_position
=
position
;
this
.
_viewPosition
=
null
;
if
(
this
.
_position
)
{
// Do not trust that widgets give a valid position
const
validModelPosition
=
this
.
_context
.
model
.
validateModelPosition
(
this
.
_position
);
if
(
this
.
_context
.
model
.
coordinatesConverter
.
modelPositionIsVisible
(
validModelPosition
))
{
this
.
_viewPosition
=
this
.
_context
.
model
.
coordinatesConverter
.
convertModelPositionToViewPosition
(
validModelPosition
);
}
}
}
private
_getMaxWidth
():
number
{
return
(
this
.
allowEditorOverflow
...
...
@@ -228,7 +265,7 @@ class Widget {
}
public
setPosition
(
position
:
IPosition
,
preference
:
ContentWidgetPositionPreference
[]):
void
{
this
.
_
position
=
position
;
this
.
_
setPosition
(
position
)
;
this
.
_preference
=
preference
;
this
.
_cachedDomNodeClientWidth
=
-
1
;
this
.
_cachedDomNodeClientHeight
=
-
1
;
...
...
@@ -318,45 +355,36 @@ class Widget {
return
new
Coordinate
(
topLeft
.
top
,
topLeft
.
left
+
this
.
_contentLeft
);
}
private
_getTopLeft
(
ctx
:
RenderingContext
,
position
:
Position
):
Coordinate
{
const
visibleRange
=
ctx
.
visibleRangeForPosition
(
position
);
if
(
!
visibleRange
)
{
/**
* Compute `this._topLeft`
*/
private
_getTopLeft
(
ctx
:
RenderingContext
):
Coordinate
{
if
(
!
this
.
_viewPosition
)
{
return
null
;
}
const
top
=
ctx
.
getVerticalOffsetForLineNumber
(
position
.
lineNumber
)
-
ctx
.
scrollTop
;
return
new
Coordinate
(
top
,
visibleRange
.
left
);
}
private
_prepareRenderWidget
(
ctx
:
RenderingContext
):
Coordinate
{
if
(
!
this
.
_position
||
!
this
.
_preference
)
{
const
visibleRange
=
ctx
.
visibleRangeForPosition
(
this
.
_viewPosition
);
if
(
!
visibleRange
)
{
return
null
;
}
// Do not trust that widgets have a valid position
let
validModelPosition
=
this
.
_context
.
model
.
validateModelPosition
(
this
.
_position
);
const
top
=
ctx
.
getVerticalOffsetForLineNumber
(
this
.
_viewPosition
.
lineNumber
)
-
ctx
.
scrollTop
;
return
new
Coordinate
(
top
,
visibleRange
.
left
);
}
if
(
!
this
.
_context
.
model
.
coordinatesConverter
.
modelPositionIsVisible
(
validModelPosition
))
{
// this position is hidden by the view model
private
_prepareRenderWidget
(
topLeft
:
Coordinate
,
ctx
:
RenderingContext
):
Coordinate
{
if
(
!
topLeft
)
{
return
null
;
}
let
position
=
this
.
_context
.
model
.
coordinatesConverter
.
convertModelPositionToViewPosition
(
validModelPosition
);
let
placement
:
IBoxLayoutResult
=
null
;
let
fetchPlacement
=
():
void
=>
{
if
(
placement
)
{
return
;
}
const
topLeft
=
this
.
_getTopLeft
(
ctx
,
position
);
if
(
!
topLeft
)
{
return
;
}
if
(
this
.
_cachedDomNodeClientWidth
===
-
1
||
this
.
_cachedDomNodeClientHeight
===
-
1
)
{
const
domNode
=
this
.
domNode
.
domNode
;
this
.
domNode
.
setMaxWidth
(
this
.
_maxWidth
);
this
.
_cachedDomNodeClientWidth
=
domNode
.
clientWidth
;
this
.
_cachedDomNodeClientHeight
=
domNode
.
clientHeight
;
}
...
...
@@ -391,11 +419,6 @@ class Widget {
return
new
Coordinate
(
placement
.
belowTop
,
placement
.
left
);
}
}
else
{
const
topLeft
=
this
.
_getTopLeft
(
ctx
,
position
);
if
(
!
topLeft
)
{
// Widget outside of viewport
return
null
;
}
if
(
this
.
allowEditorOverflow
)
{
return
this
.
_prepareRenderWidgetAtExactPositionOverflowing
(
topLeft
);
}
else
{
...
...
@@ -407,8 +430,25 @@ class Widget {
return
null
;
}
/**
* On this first pass, we ensure that the content widget (if it is in the viewport) has the max width set correctly.
*/
public
onBeforeRender
(
viewportData
:
ViewportData
):
void
{
if
(
!
this
.
_viewPosition
||
!
this
.
_preference
)
{
return
;
}
if
(
this
.
_viewPosition
.
lineNumber
<
viewportData
.
startLineNumber
||
this
.
_viewPosition
.
lineNumber
>
viewportData
.
endLineNumber
)
{
// Outside of viewport
return
;
}
this
.
domNode
.
setMaxWidth
(
this
.
_maxWidth
);
}
public
prepareRender
(
ctx
:
RenderingContext
):
void
{
this
.
_renderData
=
this
.
_prepareRenderWidget
(
ctx
);
const
topLeft
=
this
.
_getTopLeft
(
ctx
);
this
.
_renderData
=
this
.
_prepareRenderWidget
(
topLeft
,
ctx
);
}
public
render
(
ctx
:
RestrictedRenderingContext
):
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录