Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c09fa216
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,发现更多精彩内容 >>
未验证
提交
c09fa216
编写于
1月 18, 2020
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #83695: Render a content widget even if the start of the render range is outside the viewport
上级
a234f13c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
53 deletion
+45
-53
src/vs/editor/browser/view/viewImpl.ts
src/vs/editor/browser/view/viewImpl.ts
+9
-3
src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts
...editor/browser/viewParts/contentWidgets/contentWidgets.ts
+36
-50
未找到文件。
src/vs/editor/browser/view/viewImpl.ts
浏览文件 @
c09fa216
...
@@ -38,6 +38,7 @@ import { ViewCursors } from 'vs/editor/browser/viewParts/viewCursors/viewCursors
...
@@ -38,6 +38,7 @@ import { ViewCursors } from 'vs/editor/browser/viewParts/viewCursors/viewCursors
import
{
ViewZones
}
from
'
vs/editor/browser/viewParts/viewZones/viewZones
'
;
import
{
ViewZones
}
from
'
vs/editor/browser/viewParts/viewZones/viewZones
'
;
import
{
Cursor
}
from
'
vs/editor/common/controller/cursor
'
;
import
{
Cursor
}
from
'
vs/editor/common/controller/cursor
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IConfiguration
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IConfiguration
}
from
'
vs/editor/common/editorCommon
'
;
import
{
RenderingContext
}
from
'
vs/editor/common/view/renderingContext
'
;
import
{
RenderingContext
}
from
'
vs/editor/common/view/renderingContext
'
;
import
{
ViewContext
}
from
'
vs/editor/common/view/viewContext
'
;
import
{
ViewContext
}
from
'
vs/editor/common/view/viewContext
'
;
...
@@ -525,10 +526,15 @@ export class View extends ViewEventHandler {
...
@@ -525,10 +526,15 @@ export class View extends ViewEventHandler {
}
}
public
layoutContentWidget
(
widgetData
:
IContentWidgetData
):
void
{
public
layoutContentWidget
(
widgetData
:
IContentWidgetData
):
void
{
const
newPosition
=
widgetData
.
position
?
widgetData
.
position
.
position
:
null
;
let
newRange
=
widgetData
.
position
?
widgetData
.
position
.
range
||
null
:
null
;
const
newRange
=
widgetData
.
position
?
widgetData
.
position
.
range
||
null
:
null
;
if
(
newRange
===
null
)
{
const
newPosition
=
widgetData
.
position
?
widgetData
.
position
.
position
:
null
;
if
(
newPosition
!==
null
)
{
newRange
=
new
Range
(
newPosition
.
lineNumber
,
newPosition
.
column
,
newPosition
.
lineNumber
,
newPosition
.
column
);
}
}
const
newPreference
=
widgetData
.
position
?
widgetData
.
position
.
preference
:
null
;
const
newPreference
=
widgetData
.
position
?
widgetData
.
position
.
preference
:
null
;
this
.
contentWidgets
.
setWidgetPosition
(
widgetData
.
widget
,
new
Position
,
new
Range
,
newPreference
);
this
.
contentWidgets
.
setWidgetPosition
(
widgetData
.
widget
,
newRange
,
newPreference
);
this
.
_scheduleRender
();
this
.
_scheduleRender
();
}
}
...
...
src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts
浏览文件 @
c09fa216
...
@@ -7,7 +7,6 @@ import * as dom from 'vs/base/browser/dom';
...
@@ -7,7 +7,6 @@ import * as dom from 'vs/base/browser/dom';
import
{
FastDomNode
,
createFastDomNode
}
from
'
vs/base/browser/fastDomNode
'
;
import
{
FastDomNode
,
createFastDomNode
}
from
'
vs/base/browser/fastDomNode
'
;
import
{
ContentWidgetPositionPreference
,
IContentWidget
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ContentWidgetPositionPreference
,
IContentWidget
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
PartFingerprint
,
PartFingerprints
,
ViewPart
}
from
'
vs/editor/browser/view/viewPart
'
;
import
{
PartFingerprint
,
PartFingerprints
,
ViewPart
}
from
'
vs/editor/browser/view/viewPart
'
;
import
{
IPosition
,
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
IRange
,
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IRange
,
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Constants
}
from
'
vs/base/common/uint
'
;
import
{
Constants
}
from
'
vs/base/common/uint
'
;
import
{
RenderingContext
,
RestrictedRenderingContext
}
from
'
vs/editor/common/view/renderingContext
'
;
import
{
RenderingContext
,
RestrictedRenderingContext
}
from
'
vs/editor/common/view/renderingContext
'
;
...
@@ -112,9 +111,9 @@ export class ViewContentWidgets extends ViewPart {
...
@@ -112,9 +111,9 @@ export class ViewContentWidgets extends ViewPart {
this
.
setShouldRender
();
this
.
setShouldRender
();
}
}
public
setWidgetPosition
(
widget
:
IContentWidget
,
position
:
IPosition
|
null
,
range
:
IRange
|
null
,
preference
:
ContentWidgetPositionPreference
[]
|
null
):
void
{
public
setWidgetPosition
(
widget
:
IContentWidget
,
range
:
IRange
|
null
,
preference
:
ContentWidgetPositionPreference
[]
|
null
):
void
{
const
myWidget
=
this
.
_widgets
[
widget
.
getId
()];
const
myWidget
=
this
.
_widgets
[
widget
.
getId
()];
myWidget
.
setPosition
(
position
,
range
,
preference
);
myWidget
.
setPosition
(
range
,
preference
);
this
.
setShouldRender
();
this
.
setShouldRender
();
}
}
...
@@ -187,8 +186,6 @@ class Widget {
...
@@ -187,8 +186,6 @@ class Widget {
private
_contentLeft
:
number
;
private
_contentLeft
:
number
;
private
_lineHeight
:
number
;
private
_lineHeight
:
number
;
private
_position
:
IPosition
|
null
;
private
_viewPosition
:
Position
|
null
;
private
_range
:
IRange
|
null
;
private
_range
:
IRange
|
null
;
private
_viewRange
:
Range
|
null
;
private
_viewRange
:
Range
|
null
;
private
_preference
:
ContentWidgetPositionPreference
[]
|
null
;
private
_preference
:
ContentWidgetPositionPreference
[]
|
null
;
...
@@ -217,9 +214,7 @@ class Widget {
...
@@ -217,9 +214,7 @@ class Widget {
this
.
_contentLeft
=
layoutInfo
.
contentLeft
;
this
.
_contentLeft
=
layoutInfo
.
contentLeft
;
this
.
_lineHeight
=
options
.
get
(
EditorOption
.
lineHeight
);
this
.
_lineHeight
=
options
.
get
(
EditorOption
.
lineHeight
);
this
.
_position
=
null
;
this
.
_range
=
null
;
this
.
_range
=
null
;
this
.
_viewPosition
=
null
;
this
.
_viewRange
=
null
;
this
.
_viewRange
=
null
;
this
.
_preference
=
[];
this
.
_preference
=
[];
this
.
_cachedDomNodeClientWidth
=
-
1
;
this
.
_cachedDomNodeClientWidth
=
-
1
;
...
@@ -246,22 +241,13 @@ class Widget {
...
@@ -246,22 +241,13 @@ class Widget {
}
}
public
onLineMappingChanged
(
e
:
viewEvents
.
ViewLineMappingChangedEvent
):
void
{
public
onLineMappingChanged
(
e
:
viewEvents
.
ViewLineMappingChangedEvent
):
void
{
this
.
_setPosition
(
this
.
_
position
,
this
.
_
range
);
this
.
_setPosition
(
this
.
_range
);
}
}
private
_setPosition
(
position
:
IPosition
|
null
,
range
:
IRange
|
null
):
void
{
private
_setPosition
(
range
:
IRange
|
null
):
void
{
this
.
_position
=
position
;
this
.
_range
=
range
;
this
.
_range
=
range
;
this
.
_viewPosition
=
null
;
this
.
_viewRange
=
null
;
this
.
_viewRange
=
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
);
}
}
if
(
this
.
_range
)
{
if
(
this
.
_range
)
{
// Do not trust that widgets give a valid position
// Do not trust that widgets give a valid position
const
validModelRange
=
this
.
_context
.
model
.
validateModelRange
(
this
.
_range
);
const
validModelRange
=
this
.
_context
.
model
.
validateModelRange
(
this
.
_range
);
...
@@ -277,8 +263,8 @@ class Widget {
...
@@ -277,8 +263,8 @@ class Widget {
);
);
}
}
public
setPosition
(
position
:
IPosition
|
null
,
range
:
IRange
|
null
,
preference
:
ContentWidgetPositionPreference
[]
|
null
):
void
{
public
setPosition
(
range
:
IRange
|
null
,
preference
:
ContentWidgetPositionPreference
[]
|
null
):
void
{
this
.
_setPosition
(
position
,
range
);
this
.
_setPosition
(
range
);
this
.
_preference
=
preference
;
this
.
_preference
=
preference
;
this
.
_cachedDomNodeClientWidth
=
-
1
;
this
.
_cachedDomNodeClientWidth
=
-
1
;
this
.
_cachedDomNodeClientHeight
=
-
1
;
this
.
_cachedDomNodeClientHeight
=
-
1
;
...
@@ -391,45 +377,45 @@ class Widget {
...
@@ -391,45 +377,45 @@ class Widget {
* Compute `this._topLeft`
* Compute `this._topLeft`
*/
*/
private
_getTopAndBottomLeft
(
ctx
:
RenderingContext
):
[
Coordinate
,
Coordinate
]
|
[
null
,
null
]
{
private
_getTopAndBottomLeft
(
ctx
:
RenderingContext
):
[
Coordinate
,
Coordinate
]
|
[
null
,
null
]
{
if
(
!
this
.
_view
Position
)
{
if
(
!
this
.
_view
Range
)
{
return
[
null
,
null
];
return
[
null
,
null
];
}
}
const
visibleRange
ForPosition
=
ctx
.
visibleRangeForPosition
(
this
.
_viewPosition
);
const
visibleRange
sForRange
=
ctx
.
linesVisibleRangesForRange
(
this
.
_viewRange
,
false
);
if
(
!
visibleRange
ForPosition
)
{
if
(
!
visibleRange
sForRange
||
visibleRangesForRange
.
length
===
0
)
{
return
[
null
,
null
];
return
[
null
,
null
];
}
}
const
topForPosition
=
ctx
.
getVerticalOffsetForLineNumber
(
this
.
_viewPosition
.
lineNumber
)
-
ctx
.
scrollTop
;
let
firstLine
=
visibleRangesForRange
[
0
];
const
topLeft
=
new
Coordinate
(
topForPosition
,
visibleRangeForPosition
.
left
);
let
lastLine
=
visibleRangesForRange
[
0
];
for
(
const
visibleRangesForLine
of
visibleRangesForRange
)
{
let
largestLineNumber
=
this
.
_viewPosition
.
lineNumber
;
if
(
visibleRangesForLine
.
lineNumber
<
firstLine
.
lineNumber
)
{
let
smallestLeft
=
visibleRangeForPosition
.
left
;
firstLine
=
visibleRangesForLine
;
}
if
(
visibleRangesForLine
.
lineNumber
>
lastLine
.
lineNumber
)
{
lastLine
=
visibleRangesForLine
;
}
}
if
(
this
.
_viewRange
)
{
let
firstLineMinLeft
=
Constants
.
MAX_SAFE_SMALL_INTEGER
;
//firstLine.Constants.MAX_SAFE_SMALL_INTEGER;
const
visibleRangesForRange
=
ctx
.
linesVisibleRangesForRange
(
this
.
_viewRange
,
false
);
for
(
const
visibleRange
of
firstLine
.
ranges
)
{
if
(
visibleRangesForRange
&&
visibleRangesForRange
.
length
>
0
)
{
if
(
visibleRange
.
left
<
firstLineMinLeft
)
{
for
(
let
i
=
visibleRangesForRange
.
length
-
1
;
i
>=
0
;
i
--
)
{
firstLineMinLeft
=
visibleRange
.
left
;
const
visibleRangesForLine
=
visibleRangesForRange
[
i
];
}
if
(
visibleRangesForLine
.
lineNumber
>=
largestLineNumber
)
{
}
if
(
visibleRangesForLine
.
lineNumber
>
largestLineNumber
)
{
largestLineNumber
=
visibleRangesForLine
.
lineNumber
;
smallestLeft
=
Constants
.
MAX_SAFE_SMALL_INTEGER
;
}
for
(
let
j
=
0
,
lenJ
=
visibleRangesForLine
.
ranges
.
length
;
j
<
lenJ
;
j
++
)
{
const
visibleRange
=
visibleRangesForLine
.
ranges
[
j
];
if
(
visibleRange
.
left
<
smallestLeft
)
{
let
lastLineMinLeft
=
Constants
.
MAX_SAFE_SMALL_INTEGER
;
//lastLine.Constants.MAX_SAFE_SMALL_INTEGER;
smallestLeft
=
visibleRange
.
left
;
for
(
const
visibleRange
of
lastLine
.
ranges
)
{
}
if
(
visibleRange
.
left
<
lastLineMinLeft
)
{
}
lastLineMinLeft
=
visibleRange
.
left
;
}
}
}
}
}
}
const
topForBottomLine
=
ctx
.
getVerticalOffsetForLineNumber
(
largestLineNumber
)
-
ctx
.
scrollTop
;
const
topForPosition
=
ctx
.
getVerticalOffsetForLineNumber
(
firstLine
.
lineNumber
)
-
ctx
.
scrollTop
;
const
bottomLeft
=
new
Coordinate
(
topForBottomLine
,
smallestLeft
);
const
topLeft
=
new
Coordinate
(
topForPosition
,
firstLineMinLeft
);
const
topForBottomLine
=
ctx
.
getVerticalOffsetForLineNumber
(
lastLine
.
lineNumber
)
-
ctx
.
scrollTop
;
const
bottomLeft
=
new
Coordinate
(
topForBottomLine
,
lastLineMinLeft
);
return
[
topLeft
,
bottomLeft
];
return
[
topLeft
,
bottomLeft
];
}
}
...
@@ -491,11 +477,11 @@ class Widget {
...
@@ -491,11 +477,11 @@ class Widget {
* On this first pass, we ensure that the content widget (if it is in the viewport) has the max width set correctly.
* 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
{
public
onBeforeRender
(
viewportData
:
ViewportData
):
void
{
if
(
!
this
.
_view
Position
||
!
this
.
_preference
)
{
if
(
!
this
.
_view
Range
||
!
this
.
_preference
)
{
return
;
return
;
}
}
if
(
this
.
_view
Position
.
lineNumber
<
viewportData
.
startLineNumber
||
this
.
_viewPosition
.
l
ineNumber
>
viewportData
.
endLineNumber
)
{
if
(
this
.
_view
Range
.
endLineNumber
<
viewportData
.
startLineNumber
||
this
.
_viewRange
.
startL
ineNumber
>
viewportData
.
endLineNumber
)
{
// Outside of viewport
// Outside of viewport
return
;
return
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录