Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
09300167
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,体验更适合开发者的 AI 搜索 >>
提交
09300167
编写于
5月 19, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
var -> let, const
上级
ada3874b
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
50 addition
and
52 deletion
+50
-52
src/vs/editor/common/controller/cursorCollection.ts
src/vs/editor/common/controller/cursorCollection.ts
+50
-52
未找到文件。
src/vs/editor/common/controller/cursorCollection.ts
浏览文件 @
09300167
...
...
@@ -51,13 +51,6 @@ export class CursorCollection {
return
result
;
}
private
_getAll
():
OneCursor
[]
{
var
result
:
OneCursor
[]
=
[];
result
.
push
(
this
.
primaryCursor
);
result
=
result
.
concat
(
this
.
secondaryCursors
);
return
result
;
}
public
getAll
():
CursorState
[]
{
let
result
:
CursorState
[]
=
[];
result
[
0
]
=
this
.
primaryCursor
.
asCursorState
();
...
...
@@ -68,37 +61,37 @@ export class CursorCollection {
}
public
getPositions
():
Position
[]
{
var
result
:
Position
[]
=
[];
result
.
push
(
this
.
primaryCursor
.
modelState
.
position
)
;
for
(
var
i
=
0
,
len
=
this
.
secondaryCursors
.
length
;
i
<
len
;
i
++
)
{
result
.
push
(
this
.
secondaryCursors
[
i
].
modelState
.
position
)
;
let
result
:
Position
[]
=
[];
result
[
0
]
=
this
.
primaryCursor
.
modelState
.
position
;
for
(
let
i
=
0
,
len
=
this
.
secondaryCursors
.
length
;
i
<
len
;
i
++
)
{
result
[
i
+
1
]
=
this
.
secondaryCursors
[
i
].
modelState
.
position
;
}
return
result
;
}
public
getViewPositions
():
Position
[]
{
var
result
:
Position
[]
=
[];
result
.
push
(
this
.
primaryCursor
.
viewState
.
position
)
;
for
(
var
i
=
0
,
len
=
this
.
secondaryCursors
.
length
;
i
<
len
;
i
++
)
{
result
.
push
(
this
.
secondaryCursors
[
i
].
viewState
.
position
)
;
let
result
:
Position
[]
=
[];
result
[
0
]
=
this
.
primaryCursor
.
viewState
.
position
;
for
(
let
i
=
0
,
len
=
this
.
secondaryCursors
.
length
;
i
<
len
;
i
++
)
{
result
[
i
+
1
]
=
this
.
secondaryCursors
[
i
].
viewState
.
position
;
}
return
result
;
}
public
getSelections
():
Selection
[]
{
var
result
:
Selection
[]
=
[];
result
.
push
(
this
.
primaryCursor
.
modelState
.
selection
)
;
for
(
var
i
=
0
,
len
=
this
.
secondaryCursors
.
length
;
i
<
len
;
i
++
)
{
result
.
push
(
this
.
secondaryCursors
[
i
].
modelState
.
selection
)
;
let
result
:
Selection
[]
=
[];
result
[
0
]
=
this
.
primaryCursor
.
modelState
.
selection
;
for
(
let
i
=
0
,
len
=
this
.
secondaryCursors
.
length
;
i
<
len
;
i
++
)
{
result
[
i
+
1
]
=
this
.
secondaryCursors
[
i
].
modelState
.
selection
;
}
return
result
;
}
public
getViewSelections
():
Selection
[]
{
var
result
:
Selection
[]
=
[];
result
.
push
(
this
.
primaryCursor
.
viewState
.
selection
)
;
for
(
var
i
=
0
,
len
=
this
.
secondaryCursors
.
length
;
i
<
len
;
i
++
)
{
result
.
push
(
this
.
secondaryCursors
[
i
].
viewState
.
selection
)
;
let
result
:
Selection
[]
=
[];
result
[
0
]
=
this
.
primaryCursor
.
viewState
.
selection
;
for
(
let
i
=
0
,
len
=
this
.
secondaryCursors
.
length
;
i
<
len
;
i
++
)
{
result
[
i
+
1
]
=
this
.
secondaryCursors
[
i
].
viewState
.
selection
;
}
return
result
;
}
...
...
@@ -147,13 +140,8 @@ export class CursorCollection {
this
.
_setSecondaryStates
([]);
}
public
normalize
():
void
{
this
.
_mergeCursorsIfNecessary
();
}
private
_addSecondaryCursor
():
void
{
var
newCursor
=
new
OneCursor
(
this
.
context
);
this
.
secondaryCursors
.
push
(
newCursor
);
this
.
secondaryCursors
.
push
(
new
OneCursor
(
this
.
context
));
this
.
lastAddedCursorIndex
=
this
.
secondaryCursors
.
length
;
}
...
...
@@ -172,24 +160,34 @@ export class CursorCollection {
this
.
secondaryCursors
.
splice
(
removeIndex
,
1
);
}
private
_mergeCursorsIfNecessary
():
void
{
private
_getAll
():
OneCursor
[]
{
let
result
:
OneCursor
[]
=
[];
result
[
0
]
=
this
.
primaryCursor
;
for
(
let
i
=
0
,
len
=
this
.
secondaryCursors
.
length
;
i
<
len
;
i
++
)
{
result
[
i
+
1
]
=
this
.
secondaryCursors
[
i
];
}
return
result
;
}
public
normalize
():
void
{
if
(
this
.
secondaryCursors
.
length
===
0
)
{
return
;
}
var
cursors
=
this
.
_getAll
();
var
sortedCursors
:
{
let
cursors
=
this
.
_getAll
();
interface
SortedCursor
{
index
:
number
;
selection
:
Selection
;
viewSelection
:
Selection
;
}[]
=
[];
for
(
var
i
=
0
;
i
<
cursors
.
length
;
i
++
)
{
}
let
sortedCursors
:
SortedCursor
[]
=
[];
for
(
let
i
=
0
,
len
=
cursors
.
length
;
i
<
len
;
i
++
)
{
sortedCursors
.
push
({
index
:
i
,
selection
:
cursors
[
i
].
modelState
.
selection
,
viewSelection
:
cursors
[
i
].
viewState
.
selection
});
}
sortedCursors
.
sort
((
a
,
b
)
=>
{
if
(
a
.
viewSelection
.
startLineNumber
===
b
.
viewSelection
.
startLineNumber
)
{
return
a
.
viewSelection
.
startColumn
-
b
.
viewSelection
.
startColumn
;
...
...
@@ -197,30 +195,30 @@ export class CursorCollection {
return
a
.
viewSelection
.
startLineNumber
-
b
.
viewSelection
.
startLineNumber
;
});
for
(
var
sortedCursorIndex
=
0
;
sortedCursorIndex
<
sortedCursors
.
length
-
1
;
sortedCursorIndex
++
)
{
var
current
=
sortedCursors
[
sortedCursorIndex
];
var
next
=
sortedCursors
[
sortedCursorIndex
+
1
];
for
(
let
sortedCursorIndex
=
0
;
sortedCursorIndex
<
sortedCursors
.
length
-
1
;
sortedCursorIndex
++
)
{
const
current
=
sortedCursors
[
sortedCursorIndex
];
const
next
=
sortedCursors
[
sortedCursorIndex
+
1
];
var
currentViewSelection
=
current
.
viewSelection
;
var
nextViewSelection
=
next
.
viewSelection
;
const
currentViewSelection
=
current
.
viewSelection
;
const
nextViewSelection
=
next
.
viewSelection
;
if
(
nextViewSelection
.
getStartPosition
().
isBeforeOrEqual
(
currentViewSelection
.
getEndPosition
()))
{
var
winnerSortedCursorIndex
=
current
.
index
<
next
.
index
?
sortedCursorIndex
:
sortedCursorIndex
+
1
;
var
looserSortedCursorIndex
=
current
.
index
<
next
.
index
?
sortedCursorIndex
+
1
:
sortedCursorIndex
;
const
winnerSortedCursorIndex
=
current
.
index
<
next
.
index
?
sortedCursorIndex
:
sortedCursorIndex
+
1
;
const
looserSortedCursorIndex
=
current
.
index
<
next
.
index
?
sortedCursorIndex
+
1
:
sortedCursorIndex
;
var
looserIndex
=
sortedCursors
[
looserSortedCursorIndex
].
index
;
var
winnerIndex
=
sortedCursors
[
winnerSortedCursorIndex
].
index
;
const
looserIndex
=
sortedCursors
[
looserSortedCursorIndex
].
index
;
const
winnerIndex
=
sortedCursors
[
winnerSortedCursorIndex
].
index
;
var
looserSelection
=
sortedCursors
[
looserSortedCursorIndex
].
selection
;
var
winnerSelection
=
sortedCursors
[
winnerSortedCursorIndex
].
selection
;
const
looserSelection
=
sortedCursors
[
looserSortedCursorIndex
].
selection
;
const
winnerSelection
=
sortedCursors
[
winnerSortedCursorIndex
].
selection
;
if
(
!
looserSelection
.
equalsSelection
(
winnerSelection
))
{
var
resultingRange
=
looserSelection
.
plusRange
(
winnerSelection
);
var
looserSelectionIsLTR
=
(
looserSelection
.
selectionStartLineNumber
===
looserSelection
.
startLineNumber
&&
looserSelection
.
selectionStartColumn
===
looserSelection
.
startColumn
);
var
winnerSelectionIsLTR
=
(
winnerSelection
.
selectionStartLineNumber
===
winnerSelection
.
startLineNumber
&&
winnerSelection
.
selectionStartColumn
===
winnerSelection
.
startColumn
);
const
resultingRange
=
looserSelection
.
plusRange
(
winnerSelection
);
const
looserSelectionIsLTR
=
(
looserSelection
.
selectionStartLineNumber
===
looserSelection
.
startLineNumber
&&
looserSelection
.
selectionStartColumn
===
looserSelection
.
startColumn
);
const
winnerSelectionIsLTR
=
(
winnerSelection
.
selectionStartLineNumber
===
winnerSelection
.
startLineNumber
&&
winnerSelection
.
selectionStartColumn
===
winnerSelection
.
startColumn
);
// Give more importance to the last added cursor (think Ctrl-dragging + hitting another cursor)
var
resultingSelectionIsLTR
:
boolean
;
let
resultingSelectionIsLTR
:
boolean
;
if
(
looserIndex
===
this
.
lastAddedCursorIndex
)
{
resultingSelectionIsLTR
=
looserSelectionIsLTR
;
this
.
lastAddedCursorIndex
=
winnerIndex
;
...
...
@@ -229,7 +227,7 @@ export class CursorCollection {
resultingSelectionIsLTR
=
winnerSelectionIsLTR
;
}
var
resultingSelection
:
Selection
;
let
resultingSelection
:
Selection
;
if
(
resultingSelectionIsLTR
)
{
resultingSelection
=
new
Selection
(
resultingRange
.
startLineNumber
,
resultingRange
.
startColumn
,
resultingRange
.
endLineNumber
,
resultingRange
.
endColumn
);
}
else
{
...
...
@@ -241,7 +239,7 @@ export class CursorCollection {
cursors
[
winnerIndex
].
setState
(
this
.
context
,
resultingState
.
modelState
,
resultingState
.
viewState
);
}
for
(
var
j
=
0
;
j
<
sortedCursors
.
length
;
j
++
)
{
for
(
let
j
=
0
;
j
<
sortedCursors
.
length
;
j
++
)
{
if
(
sortedCursors
[
j
].
index
>
looserIndex
)
{
sortedCursors
[
j
].
index
--
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录