Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
79eda2ea
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,发现更多精彩内容 >>
提交
79eda2ea
编写于
3月 30, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Small perf tweaks
上级
4418ff2e
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
186 addition
and
144 deletion
+186
-144
src/vs/editor/browser/editorBrowser.ts
src/vs/editor/browser/editorBrowser.ts
+1
-1
src/vs/editor/browser/viewLayout/layoutProvider.ts
src/vs/editor/browser/viewLayout/layoutProvider.ts
+7
-7
src/vs/editor/browser/viewParts/lines/viewLines.ts
src/vs/editor/browser/viewParts/lines/viewLines.ts
+8
-3
src/vs/editor/browser/viewParts/overviewRuler/overviewRulerImpl.ts
...itor/browser/viewParts/overviewRuler/overviewRulerImpl.ts
+15
-9
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+16
-2
src/vs/editor/common/config/commonEditorConfig.ts
src/vs/editor/common/config/commonEditorConfig.ts
+42
-42
src/vs/editor/common/core/range.ts
src/vs/editor/common/core/range.ts
+17
-8
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+15
-6
src/vs/editor/common/model/modelLine.ts
src/vs/editor/common/model/modelLine.ts
+28
-22
src/vs/editor/common/viewLayout/linesLayout.ts
src/vs/editor/common/viewLayout/linesLayout.ts
+4
-4
src/vs/editor/common/viewLayout/viewLineParts.ts
src/vs/editor/common/viewLayout/viewLineParts.ts
+7
-22
src/vs/editor/common/viewModel/viewModelDecorations.ts
src/vs/editor/common/viewModel/viewModelDecorations.ts
+2
-2
src/vs/editor/contrib/codelens/browser/codelens.ts
src/vs/editor/contrib/codelens/browser/codelens.ts
+1
-1
src/vs/editor/contrib/links/browser/links.ts
src/vs/editor/contrib/links/browser/links.ts
+17
-5
src/vs/editor/contrib/quickOpen/common/quickOpen.ts
src/vs/editor/contrib/quickOpen/common/quickOpen.ts
+1
-1
src/vs/editor/test/common/viewLayout/viewLineParts.test.ts
src/vs/editor/test/common/viewLayout/viewLineParts.test.ts
+2
-6
src/vs/workbench/parts/search/common/searchModel.ts
src/vs/workbench/parts/search/common/searchModel.ts
+3
-3
未找到文件。
src/vs/editor/browser/editorBrowser.ts
浏览文件 @
79eda2ea
...
...
@@ -219,7 +219,7 @@ export interface ILayoutProvider extends IVerticalLayoutProvider, IScrollingProv
getCenteredViewLineNumberInViewport
():
number
;
getCurrentViewport
():
editorCommon
.
I
Viewport
;
getCurrentViewport
():
editorCommon
.
Viewport
;
onMaxLineWidthChanged
(
width
:
number
):
void
;
...
...
src/vs/editor/browser/viewLayout/layoutProvider.ts
浏览文件 @
79eda2ea
...
...
@@ -104,13 +104,13 @@ export class LayoutProvider extends ViewEventHandler implements IDisposable, ILa
// ---- Layouting logic
public
getCurrentViewport
():
editorCommon
.
I
Viewport
{
return
{
t
op
:
t
his
.
scrollable
.
getScrollTop
(),
left
:
this
.
scrollable
.
getScrollLeft
(),
width
:
this
.
scrollable
.
getWidth
(),
height
:
this
.
scrollable
.
getHeight
()
}
;
public
getCurrentViewport
():
editorCommon
.
Viewport
{
return
new
editorCommon
.
Viewport
(
this
.
scrollable
.
getScrollTop
(),
this
.
scrollable
.
getScrollLeft
(),
this
.
scrollable
.
getWidth
(),
this
.
scrollable
.
getHeight
()
)
;
}
public
getCenteredViewLineNumberInViewport
():
number
{
...
...
src/vs/editor/browser/viewParts/lines/viewLines.ts
浏览文件 @
79eda2ea
...
...
@@ -442,7 +442,7 @@ export class ViewLines extends ViewLayer {
}
}
private
_computeScrollTopToRevealRange
(
viewport
:
editorCommon
.
I
Viewport
,
range
:
editorCommon
.
IEditorRange
,
verticalType
:
editorCommon
.
VerticalRevealType
):
number
{
private
_computeScrollTopToRevealRange
(
viewport
:
editorCommon
.
Viewport
,
range
:
editorCommon
.
IEditorRange
,
verticalType
:
editorCommon
.
VerticalRevealType
):
number
{
var
viewportStartY
=
viewport
.
top
,
viewportHeight
=
viewport
.
height
,
viewportEndY
=
viewportStartY
+
viewportHeight
,
...
...
@@ -529,8 +529,13 @@ export class ViewLines extends ViewLayer {
}
private
_computeMinimumScrolling
(
viewportStart
:
number
,
viewportEnd
:
number
,
boxStart
:
number
,
boxEnd
:
number
):
number
{
var
viewportLength
=
viewportEnd
-
viewportStart
,
boxLength
=
boxEnd
-
boxStart
;
viewportStart
=
viewportStart
|
0
;
viewportEnd
=
viewportEnd
|
0
;
boxStart
=
boxStart
|
0
;
boxEnd
=
boxEnd
|
0
;
let
viewportLength
=
viewportEnd
-
viewportStart
;
let
boxLength
=
boxEnd
-
boxStart
;
if
(
boxLength
<
viewportLength
)
{
// The box would fit in the viewport
...
...
src/vs/editor/browser/viewParts/overviewRuler/overviewRulerImpl.ts
浏览文件 @
79eda2ea
...
...
@@ -175,7 +175,9 @@ class ZoneManager {
if
(
!
colorZonesInvalid
)
{
let
colorZones
=
zone
.
getColorZones
();
if
(
colorZones
)
{
allColorZones
=
allColorZones
.
concat
(
colorZones
);
for
(
let
j
=
0
,
lenJ
=
colorZones
.
length
;
j
<
lenJ
;
j
++
)
{
allColorZones
.
push
(
colorZones
[
j
]);
}
continue
;
}
}
...
...
@@ -212,7 +214,9 @@ class ZoneManager {
}
zone
.
setColorZones
(
colorZones
);
allColorZones
=
allColorZones
.
concat
(
colorZones
);
for
(
let
j
=
0
,
lenJ
=
colorZones
.
length
;
j
<
lenJ
;
j
++
)
{
allColorZones
.
push
(
colorZones
[
j
]);
}
}
this
.
_colorZonesInvalid
=
false
;
...
...
@@ -389,14 +393,16 @@ export class OverviewRulerImpl {
let
ctx
=
this
.
_domNode
.
getContext
(
'
2d
'
);
ctx
.
clearRect
(
0
,
0
,
width
,
height
);
let
remainingWidth
=
width
-
this
.
_canvasLeftOffset
;
if
(
colorZones
.
length
>
0
)
{
let
remainingWidth
=
width
-
this
.
_canvasLeftOffset
;
if
(
this
.
_lanesCount
>=
3
)
{
this
.
_renderThreeLanes
(
ctx
,
colorZones
,
id2Color
,
remainingWidth
);
}
else
if
(
this
.
_lanesCount
===
2
)
{
this
.
_renderTwoLanes
(
ctx
,
colorZones
,
id2Color
,
remainingWidth
);
}
else
if
(
this
.
_lanesCount
===
1
)
{
this
.
_renderOneLane
(
ctx
,
colorZones
,
id2Color
,
remainingWidth
);
if
(
this
.
_lanesCount
>=
3
)
{
this
.
_renderThreeLanes
(
ctx
,
colorZones
,
id2Color
,
remainingWidth
);
}
else
if
(
this
.
_lanesCount
===
2
)
{
this
.
_renderTwoLanes
(
ctx
,
colorZones
,
id2Color
,
remainingWidth
);
}
else
if
(
this
.
_lanesCount
===
1
)
{
this
.
_renderOneLane
(
ctx
,
colorZones
,
id2Color
,
remainingWidth
);
}
}
return
true
;
...
...
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
79eda2ea
...
...
@@ -488,13 +488,27 @@ export enum EditCursorState {
EndOfLastEditOperation
=
0
}
class
SingleEditOperation
{
range
:
editorCommon
.
IEditorRange
;
text
:
string
;
forceMoveMarkers
:
boolean
;
constructor
(
source
:
editorCommon
.
ISingleEditOperation
)
{
this
.
range
=
new
Range
(
source
.
range
.
startLineNumber
,
source
.
range
.
startColumn
,
source
.
range
.
endLineNumber
,
source
.
range
.
endColumn
);
this
.
text
=
source
.
text
;
this
.
forceMoveMarkers
=
source
.
forceMoveMarkers
||
false
;
}
}
export
class
CommandRunner
implements
editorCommon
.
ICommand
{
private
_ops
:
editorCommon
.
I
SingleEditOperation
[];
private
_ops
:
SingleEditOperation
[];
private
_editCursorState
:
EditCursorState
;
constructor
(
ops
:
editorCommon
.
ISingleEditOperation
[],
editCursorState
:
EditCursorState
)
{
this
.
_ops
=
ops
;
this
.
_ops
=
ops
.
map
(
op
=>
new
SingleEditOperation
(
op
))
;
this
.
_editCursorState
=
editCursorState
;
}
...
...
src/vs/editor/common/config/commonEditorConfig.ts
浏览文件 @
79eda2ea
...
...
@@ -127,27 +127,27 @@ export class InternalEditorOptions implements editorCommon.IInternalEditorOption
this
.
lineNumbers
=
input
.
lineNumbers
||
false
;
this
.
selectOnLineNumbers
=
Boolean
(
input
.
selectOnLineNumbers
);
this
.
glyphMargin
=
Boolean
(
input
.
glyphMargin
);
this
.
revealHorizontalRightPadding
=
Number
(
input
.
revealHorizontalRightPadding
);
this
.
revealHorizontalRightPadding
=
Number
(
input
.
revealHorizontalRightPadding
)
|
0
;
this
.
roundedSelection
=
Boolean
(
input
.
roundedSelection
);
this
.
theme
=
String
(
input
.
theme
);
this
.
readOnly
=
Boolean
(
input
.
readOnly
);
this
.
scrollbar
=
{
arrowSize
:
Number
(
input
.
scrollbar
.
arrowSize
),
arrowSize
:
Number
(
input
.
scrollbar
.
arrowSize
)
|
0
,
vertical
:
String
(
input
.
scrollbar
.
vertical
),
horizontal
:
String
(
input
.
scrollbar
.
horizontal
),
useShadows
:
Boolean
(
input
.
scrollbar
.
useShadows
),
verticalHasArrows
:
Boolean
(
input
.
scrollbar
.
verticalHasArrows
),
horizontalHasArrows
:
Boolean
(
input
.
scrollbar
.
horizontalHasArrows
),
handleMouseWheel
:
Boolean
(
input
.
scrollbar
.
handleMouseWheel
),
horizontalScrollbarSize
:
Number
(
input
.
scrollbar
.
horizontalScrollbarSize
),
horizontalSliderSize
:
Number
(
input
.
scrollbar
.
horizontalSliderSize
),
verticalScrollbarSize
:
Number
(
input
.
scrollbar
.
verticalScrollbarSize
),
verticalSliderSize
:
Number
(
input
.
scrollbar
.
verticalSliderSize
),
mouseWheelScrollSensitivity
:
Number
(
input
.
scrollbar
.
mouseWheelScrollSensitivity
),
horizontalScrollbarSize
:
Number
(
input
.
scrollbar
.
horizontalScrollbarSize
)
|
0
,
horizontalSliderSize
:
Number
(
input
.
scrollbar
.
horizontalSliderSize
)
|
0
,
verticalScrollbarSize
:
Number
(
input
.
scrollbar
.
verticalScrollbarSize
)
|
0
,
verticalSliderSize
:
Number
(
input
.
scrollbar
.
verticalSliderSize
)
|
0
,
mouseWheelScrollSensitivity
:
Number
(
input
.
scrollbar
.
mouseWheelScrollSensitivity
)
|
0
,
};
this
.
overviewRulerLanes
=
Number
(
input
.
overviewRulerLanes
);
this
.
overviewRulerLanes
=
Number
(
input
.
overviewRulerLanes
)
|
0
;
this
.
cursorBlinking
=
String
(
input
.
cursorBlinking
);
this
.
cursorStyle
=
Number
(
input
.
cursorStyle
);
this
.
cursorStyle
=
Number
(
input
.
cursorStyle
)
|
0
;
this
.
fontLigatures
=
Boolean
(
input
.
fontLigatures
);
this
.
hideCursorInOverviewRuler
=
Boolean
(
input
.
hideCursorInOverviewRuler
);
this
.
scrollBeyondLastLine
=
Boolean
(
input
.
scrollBeyondLastLine
);
...
...
@@ -156,14 +156,14 @@ export class InternalEditorOptions implements editorCommon.IInternalEditorOption
this
.
wordWrapBreakAfterCharacters
=
String
(
input
.
wordWrapBreakAfterCharacters
);
this
.
wordWrapBreakObtrusiveCharacters
=
String
(
input
.
wordWrapBreakObtrusiveCharacters
);
this
.
tabFocusMode
=
Boolean
(
input
.
tabFocusMode
);
this
.
stopLineTokenizationAfter
=
Number
(
input
.
stopLineTokenizationAfter
);
this
.
stopRenderingLineAfter
=
Number
(
input
.
stopRenderingLineAfter
);
this
.
longLineBoundary
=
Number
(
input
.
longLineBoundary
);
this
.
forcedTokenizationBoundary
=
Number
(
input
.
forcedTokenizationBoundary
);
this
.
stopLineTokenizationAfter
=
Number
(
input
.
stopLineTokenizationAfter
)
|
0
;
this
.
stopRenderingLineAfter
=
Number
(
input
.
stopRenderingLineAfter
)
|
0
;
this
.
longLineBoundary
=
Number
(
input
.
longLineBoundary
)
|
0
;
this
.
forcedTokenizationBoundary
=
Number
(
input
.
forcedTokenizationBoundary
)
|
0
;
this
.
hover
=
Boolean
(
input
.
hover
);
this
.
contextmenu
=
Boolean
(
input
.
contextmenu
);
this
.
quickSuggestions
=
Boolean
(
input
.
quickSuggestions
);
this
.
quickSuggestionsDelay
=
Number
(
input
.
quickSuggestionsDelay
);
this
.
quickSuggestionsDelay
=
Number
(
input
.
quickSuggestionsDelay
)
|
0
;
this
.
iconsInSuggestions
=
Boolean
(
input
.
iconsInSuggestions
);
this
.
autoClosingBrackets
=
Boolean
(
input
.
autoClosingBrackets
);
this
.
formatOnType
=
Boolean
(
input
.
formatOnType
);
...
...
@@ -175,46 +175,46 @@ export class InternalEditorOptions implements editorCommon.IInternalEditorOption
this
.
folding
=
Boolean
(
input
.
folding
);
this
.
renderWhitespace
=
Boolean
(
input
.
renderWhitespace
);
this
.
layoutInfo
=
{
width
:
Number
(
input
.
layoutInfo
.
width
),
height
:
Number
(
input
.
layoutInfo
.
height
),
glyphMarginLeft
:
Number
(
input
.
layoutInfo
.
glyphMarginLeft
),
glyphMarginWidth
:
Number
(
input
.
layoutInfo
.
glyphMarginWidth
),
glyphMarginHeight
:
Number
(
input
.
layoutInfo
.
glyphMarginHeight
),
lineNumbersLeft
:
Number
(
input
.
layoutInfo
.
lineNumbersLeft
),
lineNumbersWidth
:
Number
(
input
.
layoutInfo
.
lineNumbersWidth
),
lineNumbersHeight
:
Number
(
input
.
layoutInfo
.
lineNumbersHeight
),
decorationsLeft
:
Number
(
input
.
layoutInfo
.
decorationsLeft
),
decorationsWidth
:
Number
(
input
.
layoutInfo
.
decorationsWidth
),
decorationsHeight
:
Number
(
input
.
layoutInfo
.
decorationsHeight
),
contentLeft
:
Number
(
input
.
layoutInfo
.
contentLeft
),
contentWidth
:
Number
(
input
.
layoutInfo
.
contentWidth
),
contentHeight
:
Number
(
input
.
layoutInfo
.
contentHeight
),
verticalScrollbarWidth
:
Number
(
input
.
layoutInfo
.
verticalScrollbarWidth
),
horizontalScrollbarHeight
:
Number
(
input
.
layoutInfo
.
horizontalScrollbarHeight
),
width
:
Number
(
input
.
layoutInfo
.
width
)
|
0
,
height
:
Number
(
input
.
layoutInfo
.
height
)
|
0
,
glyphMarginLeft
:
Number
(
input
.
layoutInfo
.
glyphMarginLeft
)
|
0
,
glyphMarginWidth
:
Number
(
input
.
layoutInfo
.
glyphMarginWidth
)
|
0
,
glyphMarginHeight
:
Number
(
input
.
layoutInfo
.
glyphMarginHeight
)
|
0
,
lineNumbersLeft
:
Number
(
input
.
layoutInfo
.
lineNumbersLeft
)
|
0
,
lineNumbersWidth
:
Number
(
input
.
layoutInfo
.
lineNumbersWidth
)
|
0
,
lineNumbersHeight
:
Number
(
input
.
layoutInfo
.
lineNumbersHeight
)
|
0
,
decorationsLeft
:
Number
(
input
.
layoutInfo
.
decorationsLeft
)
|
0
,
decorationsWidth
:
Number
(
input
.
layoutInfo
.
decorationsWidth
)
|
0
,
decorationsHeight
:
Number
(
input
.
layoutInfo
.
decorationsHeight
)
|
0
,
contentLeft
:
Number
(
input
.
layoutInfo
.
contentLeft
)
|
0
,
contentWidth
:
Number
(
input
.
layoutInfo
.
contentWidth
)
|
0
,
contentHeight
:
Number
(
input
.
layoutInfo
.
contentHeight
)
|
0
,
verticalScrollbarWidth
:
Number
(
input
.
layoutInfo
.
verticalScrollbarWidth
)
|
0
,
horizontalScrollbarHeight
:
Number
(
input
.
layoutInfo
.
horizontalScrollbarHeight
)
|
0
,
overviewRuler
:{
width
:
Number
(
input
.
layoutInfo
.
overviewRuler
.
width
),
height
:
Number
(
input
.
layoutInfo
.
overviewRuler
.
height
),
top
:
Number
(
input
.
layoutInfo
.
overviewRuler
.
top
),
right
:
Number
(
input
.
layoutInfo
.
overviewRuler
.
right
),
width
:
Number
(
input
.
layoutInfo
.
overviewRuler
.
width
)
|
0
,
height
:
Number
(
input
.
layoutInfo
.
overviewRuler
.
height
)
|
0
,
top
:
Number
(
input
.
layoutInfo
.
overviewRuler
.
top
)
|
0
,
right
:
Number
(
input
.
layoutInfo
.
overviewRuler
.
right
)
|
0
,
}
};
this
.
stylingInfo
=
{
editorClassName
:
String
(
input
.
stylingInfo
.
editorClassName
),
fontFamily
:
String
(
input
.
stylingInfo
.
fontFamily
),
fontSize
:
Number
(
input
.
stylingInfo
.
fontSize
),
lineHeight
:
Number
(
input
.
stylingInfo
.
lineHeight
),
fontSize
:
Number
(
input
.
stylingInfo
.
fontSize
)
|
0
,
lineHeight
:
Number
(
input
.
stylingInfo
.
lineHeight
)
|
0
,
};
this
.
wrappingInfo
=
{
isViewportWrapping
:
Boolean
(
input
.
wrappingInfo
.
isViewportWrapping
),
wrappingColumn
:
Number
(
input
.
wrappingInfo
.
wrappingColumn
),
wrappingColumn
:
Number
(
input
.
wrappingInfo
.
wrappingColumn
)
|
0
,
};
this
.
observedOuterWidth
=
Number
(
input
.
observedOuterWidth
);
this
.
observedOuterHeight
=
Number
(
input
.
observedOuterHeight
);
this
.
lineHeight
=
Number
(
input
.
lineHeight
);
this
.
pageSize
=
Number
(
input
.
pageSize
);
this
.
observedOuterWidth
=
Number
(
input
.
observedOuterWidth
)
|
0
;
this
.
observedOuterHeight
=
Number
(
input
.
observedOuterHeight
)
|
0
;
this
.
lineHeight
=
Number
(
input
.
lineHeight
)
|
0
;
this
.
pageSize
=
Number
(
input
.
pageSize
)
|
0
;
this
.
typicalHalfwidthCharacterWidth
=
Number
(
input
.
typicalHalfwidthCharacterWidth
);
this
.
typicalFullwidthCharacterWidth
=
Number
(
input
.
typicalFullwidthCharacterWidth
);
this
.
fontSize
=
Number
(
input
.
fontSize
);
this
.
fontSize
=
Number
(
input
.
fontSize
)
|
0
;
}
}
...
...
src/vs/editor/common/core/range.ts
浏览文件 @
79eda2ea
...
...
@@ -224,17 +224,26 @@ export class Range implements IEditorRange {
* A function that compares ranges, useful for sorting ranges
* It will first compare ranges on the startPosition and then on the endPosition
*/
public
static
compareRangesUsingStarts
(
a
:
IRange
,
b
:
IRange
):
number
{
if
(
a
.
startLineNumber
===
b
.
startLineNumber
)
{
if
(
a
.
startColumn
===
b
.
startColumn
)
{
if
(
a
.
endLineNumber
===
b
.
endLineNumber
)
{
return
a
.
endColumn
-
b
.
endColumn
;
public
static
compareRangesUsingStarts
(
a
:
IEditorRange
,
b
:
IEditorRange
):
number
{
let
aStartLineNumber
=
a
.
startLineNumber
|
0
;
let
bStartLineNumber
=
b
.
startLineNumber
|
0
;
let
aStartColumn
=
a
.
startColumn
|
0
;
let
bStartColumn
=
b
.
startColumn
|
0
;
let
aEndLineNumber
=
a
.
endLineNumber
|
0
;
let
bEndLineNumber
=
b
.
endLineNumber
|
0
;
let
aEndColumn
=
a
.
endColumn
|
0
;
let
bEndColumn
=
b
.
endColumn
|
0
;
if
(
aStartLineNumber
===
bStartLineNumber
)
{
if
(
aStartColumn
===
bStartColumn
)
{
if
(
aEndLineNumber
===
bEndLineNumber
)
{
return
aEndColumn
-
bEndColumn
;
}
return
a
.
endLineNumber
-
b
.
e
ndLineNumber
;
return
a
EndLineNumber
-
bE
ndLineNumber
;
}
return
a
.
startColumn
-
b
.
s
tartColumn
;
return
a
StartColumn
-
bS
tartColumn
;
}
return
a
.
startLineNumber
-
b
.
s
tartLineNumber
;
return
a
StartLineNumber
-
bS
tartLineNumber
;
}
/**
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
79eda2ea
...
...
@@ -873,7 +873,7 @@ export interface IModelTrackedRange {
/**
* Range that this tracked range covers
*/
range
:
IRange
;
range
:
I
Editor
Range
;
}
/**
...
...
@@ -891,7 +891,7 @@ export interface IModelDecoration {
/**
* Range that this decoration covers.
*/
range
:
IRange
;
range
:
I
Editor
Range
;
/**
* Options associated with this decoration.
*/
...
...
@@ -2780,11 +2780,20 @@ export class ViewLinesViewportData {
}
}
export
interface
IViewport
{
export
class
Viewport
{
_viewportTrait
:
void
;
top
:
number
;
left
:
number
;
width
:
number
;
height
:
number
;
constructor
(
top
:
number
,
left
:
number
,
width
:
number
,
height
:
number
)
{
this
.
top
=
top
|
0
;
this
.
left
=
left
|
0
;
this
.
width
=
width
|
0
;
this
.
height
=
height
|
0
;
}
}
/**
...
...
@@ -3487,9 +3496,9 @@ export class VisibleRange {
public
width
:
number
;
constructor
(
top
:
number
,
left
:
number
,
width
:
number
)
{
this
.
top
=
top
;
this
.
left
=
left
;
this
.
width
=
width
;
this
.
top
=
top
|
0
;
this
.
left
=
left
|
0
;
this
.
width
=
width
|
0
;
}
}
...
...
src/vs/editor/common/model/modelLine.ts
浏览文件 @
79eda2ea
...
...
@@ -65,9 +65,15 @@ enum MarkerMoveSemantics {
}
export
class
ModelLine
{
public
lineNumber
:
number
;
public
text
:
string
;
public
isInvalid
:
boolean
;
private
_lineNumber
:
number
;
public
get
lineNumber
():
number
{
return
this
.
_lineNumber
;
}
private
_text
:
string
;
public
get
text
():
string
{
return
this
.
_text
;
}
private
_isInvalid
:
boolean
;
public
get
isInvalid
():
boolean
{
return
this
.
_isInvalid
;
}
public
set
isInvalid
(
value
:
boolean
)
{
this
.
_isInvalid
=
value
;
}
private
_state
:
IState
;
private
_modeTransitions
:
ModeTransition
[];
...
...
@@ -75,9 +81,9 @@ export class ModelLine {
private
_markers
:
ILineMarker
[];
constructor
(
lineNumber
:
number
,
text
:
string
)
{
this
.
lineNumber
=
lineNumber
;
this
.
text
=
text
;
this
.
isInvalid
=
false
;
this
.
_lineNumber
=
lineNumber
|
0
;
this
.
_
text
=
text
;
this
.
_
isInvalid
=
false
;
this
.
_state
=
null
;
this
.
_modeTransitions
=
null
;
this
.
_lineTokens
=
null
;
...
...
@@ -123,14 +129,14 @@ export class ModelLine {
}
private
_setLineTokensFromInflated
(
map
:
ITokensInflatorMap
,
tokens
:
IToken
[]):
void
{
let
desired
=
toLineTokensFromInflated
(
map
,
tokens
,
this
.
text
.
length
);
let
desired
=
toLineTokensFromInflated
(
map
,
tokens
,
this
.
_
text
.
length
);
this
.
_lineTokens
=
desired
;
}
private
_setLineTokensFromDeflated
(
map
:
ITokensInflatorMap
,
tokens
:
number
[]):
void
{
let
desired
=
toLineTokensFromDeflated
(
map
,
tokens
,
this
.
text
.
length
);
let
desired
=
toLineTokensFromDeflated
(
map
,
tokens
,
this
.
_
text
.
length
);
this
.
_lineTokens
=
desired
;
...
...
@@ -140,7 +146,7 @@ export class ModelLine {
if
(
this
.
_lineTokens
)
{
return
this
.
_lineTokens
;
}
if
(
this
.
text
.
length
===
0
)
{
if
(
this
.
_
text
.
length
===
0
)
{
return
EmptyLineTokens
.
INSTANCE
;
}
return
DefaultLineTokens
.
INSTANCE
;
...
...
@@ -213,13 +219,13 @@ export class ModelLine {
}
private
_setText
(
text
:
string
):
void
{
this
.
text
=
text
;
this
.
_
text
=
text
;
if
(
this
.
_lineTokens
)
{
let
BIN
=
TokensBinaryEncoding
,
map
=
this
.
_lineTokens
.
getBinaryEncodedTokensMap
(),
tokens
=
this
.
_lineTokens
.
getBinaryEncodedTokens
(),
lineTextLength
=
this
.
text
.
length
;
lineTextLength
=
this
.
_
text
.
length
;
// Remove overflowing tokens
while
(
tokens
.
length
>
0
)
{
...
...
@@ -298,7 +304,7 @@ export class ModelLine {
let
newColumn
=
Math
.
max
(
minimumAllowedColumn
,
marker
.
column
+
delta
);
if
(
marker
.
column
!==
newColumn
)
{
changedMarkers
[
marker
.
id
]
=
true
;
marker
.
oldLineNumber
=
marker
.
oldLineNumber
||
this
.
lineNumber
;
marker
.
oldLineNumber
=
marker
.
oldLineNumber
||
this
.
_
lineNumber
;
marker
.
oldColumn
=
marker
.
oldColumn
||
marker
.
column
;
marker
.
column
=
newColumn
;
}
...
...
@@ -321,7 +327,7 @@ export class ModelLine {
while
(
markersIndex
<
markersLength
&&
adjustMarkerBeforeColumn
(
toColumn
,
moveSemantics
))
{
if
(
marker
.
column
!==
newColumn
)
{
changedMarkers
[
marker
.
id
]
=
true
;
marker
.
oldLineNumber
=
marker
.
oldLineNumber
||
this
.
lineNumber
;
marker
.
oldLineNumber
=
marker
.
oldLineNumber
||
this
.
_
lineNumber
;
marker
.
oldColumn
=
marker
.
oldColumn
||
marker
.
column
;
marker
.
column
=
newColumn
;
}
...
...
@@ -350,7 +356,7 @@ export class ModelLine {
public
applyEdits
(
changedMarkers
:
IChangedMarkers
,
edits
:
ILineEdit
[]):
number
{
let
deltaColumn
=
0
;
let
resultText
=
this
.
text
;
let
resultText
=
this
.
_
text
;
let
tokensAdjuster
=
this
.
_createTokensAdjuster
();
let
markersAdjuster
=
this
.
_createMarkersAdjuster
(
changedMarkers
);
...
...
@@ -406,8 +412,8 @@ export class ModelLine {
public
split
(
changedMarkers
:
IChangedMarkers
,
splitColumn
:
number
,
forceMoveMarkers
:
boolean
):
ModelLine
{
// console.log('--> split @ ' + splitColumn + '::: ' + this._printMarkers());
var
myText
=
this
.
text
.
substring
(
0
,
splitColumn
-
1
);
var
otherText
=
this
.
text
.
substring
(
splitColumn
-
1
);
var
myText
=
this
.
_
text
.
substring
(
0
,
splitColumn
-
1
);
var
otherText
=
this
.
_
text
.
substring
(
splitColumn
-
1
);
var
otherMarkers
:
ILineMarker
[]
=
null
;
...
...
@@ -438,7 +444,7 @@ export class ModelLine {
let
marker
=
otherMarkers
[
i
];
changedMarkers
[
marker
.
id
]
=
true
;
marker
.
oldLineNumber
=
marker
.
oldLineNumber
||
this
.
lineNumber
;
marker
.
oldLineNumber
=
marker
.
oldLineNumber
||
this
.
_
lineNumber
;
marker
.
oldColumn
=
marker
.
oldColumn
||
marker
.
column
;
marker
.
column
-=
splitColumn
-
1
;
}
...
...
@@ -447,7 +453,7 @@ export class ModelLine {
this
.
_setText
(
myText
);
var
otherLine
=
new
ModelLine
(
this
.
lineNumber
+
1
,
otherText
);
var
otherLine
=
new
ModelLine
(
this
.
_
lineNumber
+
1
,
otherText
);
if
(
otherMarkers
)
{
otherLine
.
addMarkers
(
otherMarkers
);
}
...
...
@@ -457,8 +463,8 @@ export class ModelLine {
public
append
(
changedMarkers
:
IChangedMarkers
,
other
:
ModelLine
):
void
{
// console.log('--> append: THIS :: ' + this._printMarkers());
// console.log('--> append: OTHER :: ' + this._printMarkers());
var
thisTextLength
=
this
.
text
.
length
;
this
.
_setText
(
this
.
text
+
other
.
text
);
var
thisTextLength
=
this
.
_
text
.
length
;
this
.
_setText
(
this
.
_text
+
other
.
_
text
);
let
otherLineTokens
=
other
.
_lineTokens
;
if
(
otherLineTokens
)
{
...
...
@@ -587,11 +593,11 @@ export class ModelLine {
marker
=
markers
[
i
];
changedMarkers
[
marker
.
id
]
=
true
;
marker
.
oldLineNumber
=
marker
.
oldLineNumber
||
this
.
lineNumber
;
marker
.
oldLineNumber
=
marker
.
oldLineNumber
||
this
.
_
lineNumber
;
}
}
this
.
lineNumber
=
newLineNumber
;
this
.
_
lineNumber
=
newLineNumber
;
}
public
deleteLine
(
changedMarkers
:
IChangedMarkers
,
setMarkersColumn
:
number
,
setMarkersOldLineNumber
:
number
):
ILineMarker
[]
{
...
...
src/vs/editor/common/viewLayout/linesLayout.ts
浏览文件 @
79eda2ea
...
...
@@ -114,7 +114,7 @@ export class LinesLayout {
* @param reserveHorizontalScrollbarHeight The height of the horizontal scrollbar.
* @return Basically, the `scrollHeight` for the editor content.
*/
public
getTotalHeight
(
viewport
:
editorCommon
.
I
Viewport
,
reserveHorizontalScrollbarHeight
:
number
):
number
{
public
getTotalHeight
(
viewport
:
editorCommon
.
Viewport
,
reserveHorizontalScrollbarHeight
:
number
):
number
{
var
totalLinesHeight
=
this
.
getLinesTotalHeight
();
// if (this.context.configuration.editor.autoSize) {
...
...
@@ -162,7 +162,7 @@ export class LinesLayout {
* @param viewport The viewport.
* @return An array with all the whitespaces in the viewport. If no whitespace is in viewport, the array is empty.
*/
public
getWhitespaceViewportData
(
visibleBox
:
editorCommon
.
I
Viewport
):
editorCommon
.
IViewWhitespaceViewportData
[]
{
public
getWhitespaceViewportData
(
visibleBox
:
editorCommon
.
Viewport
):
editorCommon
.
IViewWhitespaceViewportData
[]
{
return
this
.
verticalObjects
.
getWhitespaceViewportData
(
visibleBox
.
top
,
visibleBox
.
top
+
visibleBox
.
height
,
this
.
_lineHeight
);
}
...
...
@@ -186,7 +186,7 @@ export class LinesLayout {
* @param viewport The viewport.
* @return A structure describing the lines positioned between `verticalOffset1` and `verticalOffset2`.
*/
public
getLinesViewportData
(
visibleBox
:
editorCommon
.
I
Viewport
):
editorCommon
.
ViewLinesViewportData
{
public
getLinesViewportData
(
visibleBox
:
editorCommon
.
Viewport
):
editorCommon
.
ViewLinesViewportData
{
let
partialData
=
this
.
verticalObjects
.
getLinesViewportData
(
visibleBox
.
top
,
visibleBox
.
top
+
visibleBox
.
height
,
this
.
_lineHeight
);
let
decorationsData
=
this
.
model
.
getDecorationsViewportData
(
partialData
.
startLineNumber
,
partialData
.
endLineNumber
);
let
visibleRange
=
new
Range
(
...
...
@@ -205,7 +205,7 @@ export class LinesLayout {
* @param viewport The viewport.
* @return The line number that is closest to the center of `viewport`.
*/
public
getCenteredLineInViewport
(
visibleBox
:
editorCommon
.
I
Viewport
):
number
{
public
getCenteredLineInViewport
(
visibleBox
:
editorCommon
.
Viewport
):
number
{
return
this
.
verticalObjects
.
getCenteredLineInViewport
(
visibleBox
.
top
,
visibleBox
.
top
+
visibleBox
.
height
,
this
.
_lineHeight
);
}
...
...
src/vs/editor/common/viewLayout/viewLineParts.ts
浏览文件 @
79eda2ea
...
...
@@ -6,7 +6,7 @@
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
Arrays
}
from
'
vs/editor/common/core/arrays
'
;
import
{
LineToken
,
IRange
,
IViewLineTokens
}
from
'
vs/editor/common/editorCommon
'
;
import
{
LineToken
,
I
Editor
Range
,
IViewLineTokens
}
from
'
vs/editor/common/editorCommon
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
export
interface
ILineParts
{
...
...
@@ -56,8 +56,8 @@ function insertWhitespace(lineNumber:number, lineContent: string, fauxIndentLeng
return
rawLineDecorations
;
}
var
prepend
:
IRange
=
null
,
append
:
IRange
=
null
,
var
prepend
:
I
Editor
Range
=
null
,
append
:
I
Editor
Range
=
null
,
computeTrailing
=
true
;
var
firstNonWhitespaceIndex
=
strings
.
firstNonWhitespaceIndex
(
lineContent
);
...
...
@@ -67,19 +67,9 @@ function insertWhitespace(lineNumber:number, lineContent: string, fauxIndentLeng
if
(
firstNonWhitespaceIndex
===
-
1
)
{
// The entire string is whitespace
computeTrailing
=
false
;
prepend
=
{
startLineNumber
:
lineNumber
,
endLineNumber
:
lineNumber
,
startColumn
:
1
,
endColumn
:
lineContent
.
length
+
1
};
prepend
=
new
Range
(
lineNumber
,
1
,
lineNumber
,
lineContent
.
length
+
1
);
}
else
{
prepend
=
{
startLineNumber
:
lineNumber
,
endLineNumber
:
lineNumber
,
startColumn
:
1
,
endColumn
:
firstNonWhitespaceIndex
+
1
};
prepend
=
new
Range
(
lineNumber
,
1
,
lineNumber
,
firstNonWhitespaceIndex
+
1
);
}
}
...
...
@@ -97,12 +87,7 @@ function insertWhitespace(lineNumber:number, lineContent: string, fauxIndentLeng
if
(
lastNonWhitespaceIndex
!==
lineContent
.
length
-
1
)
{
// There is trailing whitespace
// No need to handle the case that the entire string is empty, since it is handled above
append
=
{
startLineNumber
:
lineNumber
,
endLineNumber
:
lineNumber
,
startColumn
:
lastNonWhitespaceIndex
+
2
,
endColumn
:
lineContent
.
length
+
1
};
append
=
new
Range
(
lineNumber
,
lastNonWhitespaceIndex
+
2
,
lineNumber
,
lineContent
.
length
+
1
);
}
}
...
...
@@ -317,7 +302,7 @@ class Stack {
}
export
interface
ILineDecoration
{
range
:
IRange
;
range
:
I
Editor
Range
;
options
:
{
inlineClassName
?:
string
;
};
...
...
src/vs/editor/common/viewModel/viewModelDecorations.ts
浏览文件 @
79eda2ea
...
...
@@ -26,11 +26,11 @@ interface IViewModelDecorationSource {
class
ViewModelDecoration
implements
IViewModelDecoration
{
id
:
string
;
ownerId
:
number
;
range
:
editorCommon
.
IRange
;
range
:
editorCommon
.
I
Editor
Range
;
options
:
editorCommon
.
IModelDecorationOptions
;
modelRange
:
editorCommon
.
IRange
;
constructor
(
source
:
IViewModelDecorationSource
,
range
:
editorCommon
.
IRange
)
{
constructor
(
source
:
IViewModelDecorationSource
,
range
:
editorCommon
.
I
Editor
Range
)
{
this
.
id
=
source
.
id
;
this
.
options
=
source
.
options
;
this
.
ownerId
=
source
.
ownerId
;
...
...
src/vs/editor/contrib/codelens/browser/codelens.ts
浏览文件 @
79eda2ea
...
...
@@ -518,7 +518,7 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
if
(
!
symbols
)
{
symbols
=
[];
}
else
{
symbols
=
symbols
.
sort
((
a
,
b
)
=>
Range
.
compareRangesUsingStarts
(
a
.
symbol
.
range
,
b
.
symbol
.
range
));
symbols
=
symbols
.
sort
((
a
,
b
)
=>
Range
.
compareRangesUsingStarts
(
Range
.
lift
(
a
.
symbol
.
range
),
Range
.
lift
(
b
.
symbol
.
range
)
));
}
let
maxLineNumber
=
this
.
_editor
.
getModel
().
getLineCount
();
...
...
src/vs/editor/contrib/links/browser/links.ts
浏览文件 @
79eda2ea
...
...
@@ -76,6 +76,18 @@ class LinkOccurence {
}
}
class
Link
{
range
:
editorCommon
.
IEditorRange
;
url
:
string
;
extraInlineClassName
:
string
;
constructor
(
source
:
ILink
)
{
this
.
range
=
new
Range
(
source
.
range
.
startLineNumber
,
source
.
range
.
startColumn
,
source
.
range
.
endLineNumber
,
source
.
range
.
endColumn
);
this
.
url
=
source
.
url
;
this
.
extraInlineClassName
=
source
.
extraInlineClassName
||
null
;
}
}
class
LinkDetector
{
static
RECOMPUTE_TIME
=
1000
;
// ms
static
TRIGGER_KEY_VALUE
=
platform
.
isMacintosh
?
KeyCode
.
Meta
:
KeyCode
.
Ctrl
;
...
...
@@ -174,7 +186,7 @@ class LinkDetector {
if
(
!
b
||
b
.
length
===
0
)
{
return
a
||
[];
}
return
LinkDetector
.
_linksUnion
(
a
,
b
);
return
LinkDetector
.
_linksUnion
(
a
.
map
(
el
=>
new
Link
(
el
)),
b
.
map
(
el
=>
new
Link
(
el
))
);
});
this
.
computePromise
.
then
((
links
:
ILink
[])
=>
{
...
...
@@ -183,15 +195,15 @@ class LinkDetector {
});
}
private
static
_linksUnion
(
oldLinks
:
ILink
[],
newLinks
:
ILink
[]):
I
Link
[]
{
private
static
_linksUnion
(
oldLinks
:
Link
[],
newLinks
:
Link
[]):
Link
[]
{
// reunite oldLinks with newLinks and remove duplicates
var
result
:
I
Link
[]
=
[],
var
result
:
Link
[]
=
[],
oldIndex
:
number
,
oldLen
:
number
,
newIndex
:
number
,
newLen
:
number
,
oldLink
:
I
Link
,
newLink
:
I
Link
,
oldLink
:
Link
,
newLink
:
Link
,
comparisonResult
:
number
;
for
(
oldIndex
=
0
,
newIndex
=
0
,
oldLen
=
oldLinks
.
length
,
newLen
=
newLinks
.
length
;
oldIndex
<
oldLen
&&
newIndex
<
newLen
;)
{
...
...
src/vs/editor/contrib/quickOpen/common/quickOpen.ts
浏览文件 @
79eda2ea
...
...
@@ -65,7 +65,7 @@ export function getOutlineEntries(model: IModel): TPromise<IOutline> {
}
function
compareEntriesUsingStart
(
a
:
IOutlineEntry
,
b
:
IOutlineEntry
):
number
{
return
Range
.
compareRangesUsingStarts
(
a
.
range
,
b
.
range
);
return
Range
.
compareRangesUsingStarts
(
Range
.
lift
(
a
.
range
),
Range
.
lift
(
b
.
range
)
);
}
function
flatten
(
bucket
:
IOutlineEntry
[],
entries
:
IOutlineEntry
[],
overrideContainerLabel
:
string
):
void
{
...
...
src/vs/editor/test/common/viewLayout/viewLineParts.test.ts
浏览文件 @
79eda2ea
...
...
@@ -6,17 +6,13 @@
import
*
as
assert
from
'
assert
'
;
import
{
DecorationSegment
,
ILineDecoration
,
LineDecorationsNormalizer
}
from
'
vs/editor/common/viewLayout/viewLineParts
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
suite
(
'
Editor ViewLayout - ViewLineParts
'
,
()
=>
{
function
newDecoration
(
startLineNumber
:
number
,
startColumn
:
number
,
endLineNumber
:
number
,
endColumn
:
number
,
inlineClassName
:
string
):
ILineDecoration
{
return
{
range
:
{
startLineNumber
:
startLineNumber
,
startColumn
:
startColumn
,
endLineNumber
:
endLineNumber
,
endColumn
:
endColumn
},
range
:
new
Range
(
startLineNumber
,
startColumn
,
endLineNumber
,
endColumn
),
options
:
{
inlineClassName
:
inlineClassName
}
...
...
src/vs/workbench/parts/search/common/searchModel.ts
浏览文件 @
79eda2ea
...
...
@@ -11,7 +11,7 @@ import paths = require('vs/base/common/paths');
import
lifecycle
=
require
(
'
vs/base/common/lifecycle
'
);
import
collections
=
require
(
'
vs/base/common/collections
'
);
import
{
EventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
IModel
,
ITextModel
,
IModelDeltaDecoration
,
EventType
,
OverviewRulerLane
,
TrackedRangeStickiness
,
IModelDecorationOptions
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IModel
,
ITextModel
,
IModelDeltaDecoration
,
EventType
,
OverviewRulerLane
,
TrackedRangeStickiness
,
IModelDecorationOptions
,
I
Editor
Range
}
from
'
vs/editor/common/editorCommon
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
*
as
Search
from
'
vs/platform/search/common/search
'
;
...
...
@@ -21,7 +21,7 @@ export class Match {
private
_parent
:
FileMatch
;
private
_lineText
:
string
;
private
_id
:
string
;
private
_range
:
IRange
;
private
_range
:
I
Editor
Range
;
constructor
(
parent
:
FileMatch
,
text
:
string
,
lineNumber
:
number
,
offset
:
number
,
length
:
number
)
{
this
.
_parent
=
parent
;
...
...
@@ -42,7 +42,7 @@ export class Match {
return
this
.
_lineText
;
}
public
range
():
IRange
{
public
range
():
I
Editor
Range
{
return
this
.
_range
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录