Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
993c1595
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,发现更多精彩内容 >>
未验证
提交
993c1595
编写于
5月 15, 2020
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Have the Cursor not be a ViewEventEmitter
上级
48dc035b
变更
12
展开全部
隐藏空白更改
内联
并排
Showing
12 changed file
with
822 addition
and
783 deletion
+822
-783
src/vs/editor/browser/controller/coreCommands.ts
src/vs/editor/browser/controller/coreCommands.ts
+71
-80
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+3
-3
src/vs/editor/common/controller/cursor.ts
src/vs/editor/common/controller/cursor.ts
+71
-76
src/vs/editor/common/controller/cursorCollection.ts
src/vs/editor/common/controller/cursorCollection.ts
+22
-0
src/vs/editor/common/controller/cursorCommon.ts
src/vs/editor/common/controller/cursorCommon.ts
+1
-7
src/vs/editor/common/viewModel/viewModel.ts
src/vs/editor/common/viewModel/viewModel.ts
+13
-2
src/vs/editor/common/viewModel/viewModelImpl.ts
src/vs/editor/common/viewModel/viewModelImpl.ts
+53
-29
src/vs/editor/contrib/multicursor/multicursor.ts
src/vs/editor/contrib/multicursor/multicursor.ts
+6
-5
src/vs/editor/contrib/wordOperations/wordOperations.ts
src/vs/editor/contrib/wordOperations/wordOperations.ts
+1
-1
src/vs/editor/test/browser/controller/cursor.test.ts
src/vs/editor/test/browser/controller/cursor.test.ts
+534
-534
src/vs/editor/test/browser/controller/cursorMoveCommand.test.ts
.../editor/test/browser/controller/cursorMoveCommand.test.ts
+44
-44
src/vs/workbench/contrib/codeEditor/browser/toggleColumnSelection.ts
...bench/contrib/codeEditor/browser/toggleColumnSelection.ts
+3
-2
未找到文件。
src/vs/editor/browser/controller/coreCommands.ts
浏览文件 @
993c1595
此差异已折叠。
点击以展开。
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
993c1595
...
...
@@ -555,7 +555,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
const
validatedModelRange
=
this
.
_modelData
.
model
.
validateRange
(
modelRange
);
const
viewRange
=
this
.
_modelData
.
viewModel
.
coordinatesConverter
.
convertModelRangeToViewRange
(
validatedModelRange
);
this
.
_modelData
.
viewModel
.
cursor
.
emitCursorRevealRange
(
'
api
'
,
viewRange
,
null
,
verticalType
,
revealHorizontal
,
scrollType
);
this
.
_modelData
.
viewModel
.
revealRange
(
'
api
'
,
revealHorizontal
,
viewRange
,
verticalType
,
scrollType
);
}
public
revealLine
(
lineNumber
:
number
,
scrollType
:
editorCommon
.
ScrollType
=
editorCommon
.
ScrollType
.
Smooth
):
void
{
...
...
@@ -1544,7 +1544,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
if
(
this
.
isSimpleWidget
)
{
commandDelegate
=
{
executeEditorCommand
:
(
editorCommand
:
CoreEditorCommand
,
args
:
any
):
void
=>
{
editorCommand
.
runCoreEditorCommand
(
viewModel
.
getCursors
(),
args
);
editorCommand
.
runCoreEditorCommand
(
this
,
viewModel
,
viewModel
.
getCursors
(),
args
);
},
paste
:
(
text
:
string
,
pasteOnNewLine
:
boolean
,
multicursorText
:
string
[]
|
null
,
mode
:
string
|
null
)
=>
{
this
.
_paste
(
'
keyboard
'
,
text
,
pasteOnNewLine
,
multicursorText
,
mode
);
...
...
@@ -1568,7 +1568,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
}
else
{
commandDelegate
=
{
executeEditorCommand
:
(
editorCommand
:
CoreEditorCommand
,
args
:
any
):
void
=>
{
editorCommand
.
runCoreEditorCommand
(
viewModel
.
getCursors
(),
args
);
editorCommand
.
runCoreEditorCommand
(
this
,
viewModel
,
viewModel
.
getCursors
(),
args
);
},
paste
:
(
text
:
string
,
pasteOnNewLine
:
boolean
,
multicursorText
:
string
[]
|
null
,
mode
:
string
|
null
)
=>
{
const
payload
:
editorCommon
.
PastePayload
=
{
text
,
pasteOnNewLine
,
multicursorText
,
mode
};
...
...
src/vs/editor/common/controller/cursor.ts
浏览文件 @
993c1595
...
...
@@ -7,7 +7,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
CursorCollection
}
from
'
vs/editor/common/controller/cursorCollection
'
;
import
{
CursorColumns
,
CursorConfiguration
,
CursorContext
,
CursorState
,
EditOperationResult
,
EditOperationType
,
IColumnSelectData
,
ICursors
,
PartialCursorState
,
RevealTarget
,
ICursorSimpleModel
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
CursorColumns
,
CursorConfiguration
,
CursorContext
,
CursorState
,
EditOperationResult
,
EditOperationType
,
IColumnSelectData
,
ICursors
,
PartialCursorState
,
ICursorSimpleModel
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
DeleteOperations
}
from
'
vs/editor/common/controller/cursorDeleteOperations
'
;
import
{
CursorChangeReason
}
from
'
vs/editor/common/controller/cursorEvents
'
;
import
{
TypeOperations
,
TypeWithAutoClosingCommand
}
from
'
vs/editor/common/controller/cursorTypeOperations
'
;
...
...
@@ -17,8 +17,8 @@ import { ISelection, Selection, SelectionDirection } from 'vs/editor/common/core
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
ITextModel
,
TrackedRangeStickiness
,
IModelDeltaDecoration
,
ICursorStateComputer
,
IIdentifiedSingleEditOperation
,
IValidEditOperation
}
from
'
vs/editor/common/model
'
;
import
{
RawContentChangedType
,
ModelRawContentChangedEvent
,
IModelLanguageChangedEvent
}
from
'
vs/editor/common/model/textModelEvents
'
;
import
*
as
viewEvents
from
'
vs/editor/common/view/viewEvents
'
;
import
{
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
ViewEventsCollector
,
VerticalRevealType
,
ViewCursorStateChangedEvent
,
ViewRevealRangeRequestEvent
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
dispose
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
EditorOption
,
ConfigurationChangedEvent
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
ICoordinatesConverter
}
from
'
vs/editor/common/viewModel/viewModel
'
;
...
...
@@ -162,7 +162,7 @@ class AutoClosedAction {
}
}
export
class
Cursor
extends
viewEvents
.
ViewEventEmitter
implements
ICursors
{
export
class
Cursor
extends
Disposable
implements
ICursors
{
public
static
readonly
MAX_CURSOR_COUNT
=
10000
;
...
...
@@ -218,7 +218,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
this
.
_cursors
.
updateContext
(
this
.
context
);
}
public
onLineMappingChanged
():
void
{
public
onLineMappingChanged
(
eventsCollector
:
ViewEventsCollector
):
void
{
if
(
this
.
_knownModelVersionId
!==
this
.
_model
.
getVersionId
())
{
// There are model change events that I didn't yet receive.
//
...
...
@@ -230,7 +230,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
return
;
}
// Ensure valid state
this
.
setStates
(
'
viewModel
'
,
CursorChangeReason
.
NotSet
,
this
.
getAll
());
this
.
setStates
(
eventsCollector
,
'
viewModel
'
,
CursorChangeReason
.
NotSet
,
this
.
getAll
());
}
public
onDidChangeModelLanguage
(
e
:
IModelLanguageChangedEvent
):
void
{
...
...
@@ -283,7 +283,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
return
this
.
_cursors
.
getAll
();
}
public
setStates
(
source
:
string
|
null
|
undefined
,
reason
:
CursorChangeReason
,
states
:
PartialCursorState
[]
|
null
):
boolean
{
public
setStates
(
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
reason
:
CursorChangeReason
,
states
:
PartialCursorState
[]
|
null
):
boolean
{
let
reachedMaxCursorCount
=
false
;
if
(
states
!==
null
&&
states
.
length
>
Cursor
.
MAX_CURSOR_COUNT
)
{
states
=
states
.
slice
(
0
,
Cursor
.
MAX_CURSOR_COUNT
);
...
...
@@ -298,19 +298,38 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
this
.
_validateAutoClosedActions
();
return
this
.
_emitStateChangedIfNecessary
(
source
,
reason
,
oldState
,
reachedMaxCursorCount
);
return
this
.
_emitStateChangedIfNecessary
(
eventsCollector
,
source
,
reason
,
oldState
,
reachedMaxCursorCount
);
}
public
setColumnSelectData
(
columnSelectData
:
IColumnSelectData
):
void
{
this
.
_columnSelectData
=
columnSelectData
;
}
public
reveal
(
source
:
string
|
null
|
undefined
,
horizontal
:
boolean
,
target
:
RevealTarget
,
scrollType
:
editorCommon
.
ScrollType
):
void
{
this
.
_revealRange
(
source
,
target
,
viewEvents
.
VerticalRevealType
.
Simple
,
horizontal
,
scrollType
);
public
revealPrimary
(
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
revealHorizontal
:
boolean
,
scrollType
:
editorCommon
.
ScrollType
):
void
{
const
viewPositions
=
this
.
_cursors
.
getViewPositions
();
if
(
viewPositions
.
length
>
1
)
{
this
.
_emitCursorRevealRange
(
eventsCollector
,
source
,
null
,
this
.
_cursors
.
getViewSelections
(),
VerticalRevealType
.
Simple
,
revealHorizontal
,
scrollType
);
return
;
}
else
{
const
viewPosition
=
viewPositions
[
0
];
const
viewRange
=
new
Range
(
viewPosition
.
lineNumber
,
viewPosition
.
column
,
viewPosition
.
lineNumber
,
viewPosition
.
column
);
this
.
_emitCursorRevealRange
(
eventsCollector
,
source
,
viewRange
,
null
,
VerticalRevealType
.
Simple
,
revealHorizontal
,
scrollType
);
}
}
public
revealRange
(
source
:
string
|
null
|
undefined
,
revealHorizontal
:
boolean
,
viewRange
:
Range
,
verticalType
:
viewEvents
.
VerticalRevealType
,
scrollType
:
editorCommon
.
ScrollType
)
{
this
.
emitCursorRevealRange
(
source
,
viewRange
,
null
,
verticalType
,
revealHorizontal
,
scrollType
);
private
_revealPrimaryCursor
(
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
verticalType
:
VerticalRevealType
,
revealHorizontal
:
boolean
,
scrollType
:
editorCommon
.
ScrollType
):
void
{
const
viewPositions
=
this
.
_cursors
.
getViewPositions
();
if
(
viewPositions
.
length
>
1
)
{
this
.
_emitCursorRevealRange
(
eventsCollector
,
source
,
null
,
this
.
_cursors
.
getViewSelections
(),
verticalType
,
revealHorizontal
,
scrollType
);
}
else
{
const
viewPosition
=
viewPositions
[
0
];
const
viewRange
=
new
Range
(
viewPosition
.
lineNumber
,
viewPosition
.
column
,
viewPosition
.
lineNumber
,
viewPosition
.
column
);
this
.
_emitCursorRevealRange
(
eventsCollector
,
source
,
viewRange
,
null
,
verticalType
,
revealHorizontal
,
scrollType
);
}
}
private
_emitCursorRevealRange
(
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
viewRange
:
Range
|
null
,
viewSelections
:
Selection
[]
|
null
,
verticalType
:
VerticalRevealType
,
revealHorizontal
:
boolean
,
scrollType
:
editorCommon
.
ScrollType
)
{
eventsCollector
.
emit
(
new
ViewRevealRangeRequestEvent
(
source
,
viewRange
,
viewSelections
,
verticalType
,
revealHorizontal
,
scrollType
));
}
public
saveState
():
editorCommon
.
ICursorState
[]
{
...
...
@@ -337,7 +356,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
return
result
;
}
public
restoreState
(
states
:
editorCommon
.
ICursorState
[]):
void
{
public
restoreState
(
eventsCollector
:
ViewEventsCollector
,
states
:
editorCommon
.
ICursorState
[]):
void
{
let
desiredSelections
:
ISelection
[]
=
[];
...
...
@@ -374,11 +393,11 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
});
}
this
.
setStates
(
'
restoreState
'
,
CursorChangeReason
.
NotSet
,
CursorState
.
fromModelSelections
(
desiredSelections
));
this
.
reveal
(
'
restoreState
'
,
true
,
RevealTarget
.
Primary
,
editorCommon
.
ScrollType
.
Immediate
);
this
.
setStates
(
eventsCollector
,
'
restoreState
'
,
CursorChangeReason
.
NotSet
,
CursorState
.
fromModelSelections
(
desiredSelections
));
this
.
reveal
Primary
(
eventsCollector
,
'
restoreState
'
,
true
,
editorCommon
.
ScrollType
.
Immediate
);
}
public
onModelContentChanged
(
e
:
ModelRawContentChangedEvent
):
void
{
public
onModelContentChanged
(
e
ventsCollector
:
ViewEventsCollector
,
e
:
ModelRawContentChangedEvent
):
void
{
this
.
_knownModelVersionId
=
e
.
versionId
;
if
(
this
.
_isHandling
)
{
...
...
@@ -393,16 +412,16 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
this
.
_cursors
.
dispose
();
this
.
_cursors
=
new
CursorCollection
(
this
.
context
);
this
.
_validateAutoClosedActions
();
this
.
_emitStateChangedIfNecessary
(
'
model
'
,
CursorChangeReason
.
ContentFlush
,
null
,
false
);
this
.
_emitStateChangedIfNecessary
(
eventsCollector
,
'
model
'
,
CursorChangeReason
.
ContentFlush
,
null
,
false
);
}
else
{
if
(
this
.
_hasFocus
&&
e
.
resultingSelection
&&
e
.
resultingSelection
.
length
>
0
)
{
const
cursorState
=
CursorState
.
fromModelSelections
(
e
.
resultingSelection
);
if
(
this
.
setStates
(
'
modelChange
'
,
e
.
isUndoing
?
CursorChangeReason
.
Undo
:
e
.
isRedoing
?
CursorChangeReason
.
Redo
:
CursorChangeReason
.
RecoverFromMarkers
,
cursorState
))
{
this
.
_reveal
Range
(
'
modelChange
'
,
RevealTarget
.
Primary
,
viewEvents
.
VerticalRevealType
.
Simple
,
true
,
editorCommon
.
ScrollType
.
Smooth
);
if
(
this
.
setStates
(
eventsCollector
,
'
modelChange
'
,
e
.
isUndoing
?
CursorChangeReason
.
Undo
:
e
.
isRedoing
?
CursorChangeReason
.
Redo
:
CursorChangeReason
.
RecoverFromMarkers
,
cursorState
))
{
this
.
_reveal
PrimaryCursor
(
eventsCollector
,
'
modelChange
'
,
VerticalRevealType
.
Simple
,
true
,
editorCommon
.
ScrollType
.
Smooth
);
}
}
else
{
const
selectionsFromMarkers
=
this
.
_cursors
.
readSelectionFromMarkers
();
this
.
setStates
(
'
modelChange
'
,
CursorChangeReason
.
RecoverFromMarkers
,
CursorState
.
fromModelSelections
(
selectionsFromMarkers
));
this
.
setStates
(
eventsCollector
,
'
modelChange
'
,
CursorChangeReason
.
RecoverFromMarkers
,
CursorState
.
fromModelSelections
(
selectionsFromMarkers
));
}
}
}
...
...
@@ -411,6 +430,14 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
return
this
.
_cursors
.
getPrimaryCursor
().
modelState
.
selection
;
}
public
getTopMostViewPosition
():
Position
{
return
this
.
_cursors
.
getTopMostViewPosition
();
}
public
getBottomMostViewPosition
():
Position
{
return
this
.
_cursors
.
getBottomMostViewPosition
();
}
public
getColumnSelectData
():
IColumnSelectData
{
if
(
this
.
_columnSelectData
)
{
return
this
.
_columnSelectData
;
...
...
@@ -435,8 +462,8 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
return
this
.
_cursors
.
getPrimaryCursor
().
modelState
.
position
;
}
public
setSelections
(
source
:
string
|
null
|
undefined
,
selections
:
readonly
ISelection
[]):
void
{
this
.
setStates
(
source
,
CursorChangeReason
.
NotSet
,
CursorState
.
fromModelSelections
(
selections
));
public
setSelections
(
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
selections
:
readonly
ISelection
[]):
void
{
this
.
setStates
(
eventsCollector
,
source
,
CursorChangeReason
.
NotSet
,
CursorState
.
fromModelSelections
(
selections
));
}
public
getPrevEditOperationType
():
EditOperationType
{
...
...
@@ -527,7 +554,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
// -----------------------------------------------------------------------------------------------------------
// ----- emitting events
private
_emitStateChangedIfNecessary
(
source
:
string
|
null
|
undefined
,
reason
:
CursorChangeReason
,
oldState
:
CursorModelState
|
null
,
reachedMaxCursorCount
:
boolean
):
boolean
{
private
_emitStateChangedIfNecessary
(
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
reason
:
CursorChangeReason
,
oldState
:
CursorModelState
|
null
,
reachedMaxCursorCount
:
boolean
):
boolean
{
const
newState
=
new
CursorModelState
(
this
.
_model
,
this
);
if
(
newState
.
equals
(
oldState
))
{
return
false
;
...
...
@@ -537,7 +564,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
const
viewSelections
=
this
.
_cursors
.
getViewSelections
();
// Let the view get the event first.
this
.
_emitSingleViewEvent
(
new
viewEvents
.
ViewCursorStateChangedEvent
(
viewSelections
,
selections
));
eventsCollector
.
emit
(
new
ViewCursorStateChangedEvent
(
viewSelections
,
selections
));
// Only after the view has been notified, let the rest of the world know...
if
(
!
oldState
...
...
@@ -552,38 +579,6 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
return
true
;
}
private
_revealRange
(
source
:
string
|
null
|
undefined
,
revealTarget
:
RevealTarget
,
verticalType
:
viewEvents
.
VerticalRevealType
,
revealHorizontal
:
boolean
,
scrollType
:
editorCommon
.
ScrollType
):
void
{
const
viewPositions
=
this
.
_cursors
.
getViewPositions
();
let
viewPosition
=
viewPositions
[
0
];
if
(
revealTarget
===
RevealTarget
.
TopMost
)
{
for
(
let
i
=
1
;
i
<
viewPositions
.
length
;
i
++
)
{
if
(
viewPositions
[
i
].
isBefore
(
viewPosition
))
{
viewPosition
=
viewPositions
[
i
];
}
}
}
else
if
(
revealTarget
===
RevealTarget
.
BottomMost
)
{
for
(
let
i
=
1
;
i
<
viewPositions
.
length
;
i
++
)
{
if
(
viewPosition
.
isBeforeOrEqual
(
viewPositions
[
i
]))
{
viewPosition
=
viewPositions
[
i
];
}
}
}
else
{
if
(
viewPositions
.
length
>
1
)
{
this
.
emitCursorRevealRange
(
source
,
null
,
this
.
_cursors
.
getViewSelections
(),
verticalType
,
revealHorizontal
,
scrollType
);
return
;
}
}
const
viewRange
=
new
Range
(
viewPosition
.
lineNumber
,
viewPosition
.
column
,
viewPosition
.
lineNumber
,
viewPosition
.
column
);
this
.
emitCursorRevealRange
(
source
,
viewRange
,
null
,
verticalType
,
revealHorizontal
,
scrollType
);
}
public
emitCursorRevealRange
(
source
:
string
|
null
|
undefined
,
viewRange
:
Range
|
null
,
viewSelections
:
Selection
[]
|
null
,
verticalType
:
viewEvents
.
VerticalRevealType
,
revealHorizontal
:
boolean
,
scrollType
:
editorCommon
.
ScrollType
)
{
this
.
_emitSingleViewEvent
(
new
viewEvents
.
ViewRevealRangeRequestEvent
(
source
,
viewRange
,
viewSelections
,
verticalType
,
revealHorizontal
,
scrollType
));
}
// -----------------------------------------------------------------------------------------------------------
// ----- handlers beyond this point
...
...
@@ -623,7 +618,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
return
indices
;
}
public
executeEdits
(
source
:
string
|
null
|
undefined
,
edits
:
IIdentifiedSingleEditOperation
[],
cursorStateComputer
:
ICursorStateComputer
):
void
{
public
executeEdits
(
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
edits
:
IIdentifiedSingleEditOperation
[],
cursorStateComputer
:
ICursorStateComputer
):
void
{
let
autoClosingIndices
:
[
number
,
number
][]
|
null
=
null
;
if
(
source
===
'
snippet
'
)
{
autoClosingIndices
=
this
.
_findAutoClosingPairs
(
edits
);
...
...
@@ -658,14 +653,14 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
});
if
(
selections
)
{
this
.
_isHandling
=
false
;
this
.
setSelections
(
source
,
selections
);
this
.
setSelections
(
eventsCollector
,
source
,
selections
);
}
if
(
autoClosedCharactersRanges
.
length
>
0
)
{
this
.
_pushAutoClosedAction
(
autoClosedCharactersRanges
,
autoClosedEnclosingRanges
);
}
}
private
_executeEdit
(
callback
:
()
=>
void
,
source
:
string
|
null
|
undefined
,
cursorChangeReason
:
CursorChangeReason
=
CursorChangeReason
.
NotSet
):
void
{
private
_executeEdit
(
callback
:
()
=>
void
,
eventsCollector
:
ViewEventsCollector
,
source
:
string
|
null
|
undefined
,
cursorChangeReason
:
CursorChangeReason
=
CursorChangeReason
.
NotSet
):
void
{
if
(
this
.
_configuration
.
options
.
get
(
EditorOption
.
readOnly
))
{
// we cannot edit when read only...
this
.
_onDidAttemptReadOnlyEdit
.
fire
(
undefined
);
...
...
@@ -686,17 +681,17 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
this
.
_isHandling
=
false
;
this
.
_cursors
.
startTrackingSelections
();
this
.
_validateAutoClosedActions
();
if
(
this
.
_emitStateChangedIfNecessary
(
source
,
cursorChangeReason
,
oldState
,
false
))
{
this
.
_reveal
Range
(
source
,
RevealTarget
.
Primary
,
viewEvents
.
VerticalRevealType
.
Simple
,
true
,
editorCommon
.
ScrollType
.
Smooth
);
if
(
this
.
_emitStateChangedIfNecessary
(
eventsCollector
,
source
,
cursorChangeReason
,
oldState
,
false
))
{
this
.
_reveal
PrimaryCursor
(
eventsCollector
,
source
,
VerticalRevealType
.
Simple
,
true
,
editorCommon
.
ScrollType
.
Smooth
);
}
}
public
startComposition
():
void
{
public
startComposition
(
eventsCollector
:
ViewEventsCollector
):
void
{
this
.
_isDoingComposition
=
true
;
this
.
_selectionsWhenCompositionStarted
=
this
.
getSelections
().
slice
(
0
);
}
public
endComposition
(
source
?:
string
|
null
|
undefined
):
void
{
public
endComposition
(
eventsCollector
:
ViewEventsCollector
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
_isDoingComposition
=
false
;
this
.
_executeEdit
(()
=>
{
if
(
!
this
.
_isDoingComposition
&&
source
===
'
keyboard
'
)
{
...
...
@@ -705,10 +700,10 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
this
.
_executeEditOperation
(
TypeOperations
.
compositionEndWithInterceptors
(
this
.
_prevEditOperationType
,
this
.
context
.
config
,
this
.
context
.
model
,
this
.
_selectionsWhenCompositionStarted
,
this
.
getSelections
(),
autoClosedCharacters
));
this
.
_selectionsWhenCompositionStarted
=
null
;
}
},
source
);
},
eventsCollector
,
source
);
}
public
type
(
text
:
string
,
source
?:
string
|
null
|
undefined
):
void
{
public
type
(
eventsCollector
:
ViewEventsCollector
,
text
:
string
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
_executeEdit
(()
=>
{
if
(
source
===
'
keyboard
'
)
{
// If this event is coming straight from the keyboard, look for electric characters and enter
...
...
@@ -729,28 +724,28 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
}
else
{
this
.
_executeEditOperation
(
TypeOperations
.
typeWithoutInterceptors
(
this
.
_prevEditOperationType
,
this
.
context
.
config
,
this
.
context
.
model
,
this
.
getSelections
(),
text
));
}
},
source
);
},
eventsCollector
,
source
);
}
public
replacePreviousChar
(
text
:
string
,
replaceCharCnt
:
number
,
source
?:
string
|
null
|
undefined
):
void
{
public
replacePreviousChar
(
eventsCollector
:
ViewEventsCollector
,
text
:
string
,
replaceCharCnt
:
number
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
_executeEdit
(()
=>
{
this
.
_executeEditOperation
(
TypeOperations
.
replacePreviousChar
(
this
.
_prevEditOperationType
,
this
.
context
.
config
,
this
.
context
.
model
,
this
.
getSelections
(),
text
,
replaceCharCnt
));
},
source
);
},
eventsCollector
,
source
);
}
public
paste
(
text
:
string
,
pasteOnNewLine
:
boolean
,
multicursorText
?:
string
[]
|
null
|
undefined
,
source
?:
string
|
null
|
undefined
):
void
{
public
paste
(
eventsCollector
:
ViewEventsCollector
,
text
:
string
,
pasteOnNewLine
:
boolean
,
multicursorText
?:
string
[]
|
null
|
undefined
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
_executeEdit
(()
=>
{
this
.
_executeEditOperation
(
TypeOperations
.
paste
(
this
.
context
.
config
,
this
.
context
.
model
,
this
.
getSelections
(),
text
,
pasteOnNewLine
,
multicursorText
||
[]));
},
source
,
CursorChangeReason
.
Paste
);
},
eventsCollector
,
source
,
CursorChangeReason
.
Paste
);
}
public
cut
(
source
?:
string
|
null
|
undefined
):
void
{
public
cut
(
eventsCollector
:
ViewEventsCollector
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
_executeEdit
(()
=>
{
this
.
_executeEditOperation
(
DeleteOperations
.
cut
(
this
.
context
.
config
,
this
.
context
.
model
,
this
.
getSelections
()));
},
source
);
},
eventsCollector
,
source
);
}
public
executeCommand
(
command
:
editorCommon
.
ICommand
,
source
?:
string
|
null
|
undefined
):
void
{
public
executeCommand
(
eventsCollector
:
ViewEventsCollector
,
command
:
editorCommon
.
ICommand
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
_executeEdit
(()
=>
{
this
.
_cursors
.
killSecondaryCursors
();
...
...
@@ -758,16 +753,16 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
shouldPushStackElementBefore
:
false
,
shouldPushStackElementAfter
:
false
}));
},
source
);
},
eventsCollector
,
source
);
}
public
executeCommands
(
commands
:
editorCommon
.
ICommand
[],
source
?:
string
|
null
|
undefined
):
void
{
public
executeCommands
(
eventsCollector
:
ViewEventsCollector
,
commands
:
editorCommon
.
ICommand
[],
source
?:
string
|
null
|
undefined
):
void
{
this
.
_executeEdit
(()
=>
{
this
.
_executeEditOperation
(
new
EditOperationResult
(
EditOperationType
.
Other
,
commands
,
{
shouldPushStackElementBefore
:
false
,
shouldPushStackElementAfter
:
false
}));
},
source
);
},
eventsCollector
,
source
);
}
}
...
...
src/vs/editor/common/controller/cursorCollection.ts
浏览文件 @
993c1595
...
...
@@ -82,6 +82,28 @@ export class CursorCollection {
return
result
;
}
public
getTopMostViewPosition
():
Position
{
let
result
=
this
.
primaryCursor
.
viewState
.
position
;
for
(
let
i
=
0
,
len
=
this
.
secondaryCursors
.
length
;
i
<
len
;
i
++
)
{
const
viewPosition
=
this
.
secondaryCursors
[
i
].
viewState
.
position
;
if
(
viewPosition
.
isBefore
(
result
))
{
result
=
viewPosition
;
}
}
return
result
;
}
public
getBottomMostViewPosition
():
Position
{
let
result
=
this
.
primaryCursor
.
viewState
.
position
;
for
(
let
i
=
0
,
len
=
this
.
secondaryCursors
.
length
;
i
<
len
;
i
++
)
{
const
viewPosition
=
this
.
secondaryCursors
[
i
].
viewState
.
position
;
if
(
result
.
isBeforeOrEqual
(
viewPosition
))
{
result
=
viewPosition
;
}
}
return
result
;
}
public
getSelections
():
Selection
[]
{
let
result
:
Selection
[]
=
[];
result
[
0
]
=
this
.
primaryCursor
.
modelState
.
selection
;
...
...
src/vs/editor/common/controller/cursorCommon.ts
浏览文件 @
993c1595
...
...
@@ -7,17 +7,15 @@ import { CharCode } from 'vs/base/common/charCode';
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
EditorAutoClosingStrategy
,
EditorAutoSurroundStrategy
,
ConfigurationChangedEvent
,
EditorAutoClosingOvertypeStrategy
,
EditorOption
,
EditorAutoIndentStrategy
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
CursorChangeReason
}
from
'
vs/editor/common/controller/cursorEvents
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
ISelection
,
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
ICommand
,
IConfiguration
,
ScrollType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommand
,
IConfiguration
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ITextModel
,
TextModelResolvedOptions
}
from
'
vs/editor/common/model
'
;
import
{
TextModel
}
from
'
vs/editor/common/model/textModel
'
;
import
{
LanguageIdentifier
}
from
'
vs/editor/common/modes
'
;
import
{
IAutoClosingPair
,
StandardAutoClosingPairConditional
}
from
'
vs/editor/common/modes/languageConfiguration
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
VerticalRevealType
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
ICoordinatesConverter
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
Constants
}
from
'
vs/base/common/uint
'
;
...
...
@@ -55,10 +53,6 @@ export interface ICursors {
getColumnSelectData
():
IColumnSelectData
;
setColumnSelectData
(
columnSelectData
:
IColumnSelectData
):
void
;
setStates
(
source
:
string
|
null
|
undefined
,
reason
:
CursorChangeReason
,
states
:
PartialCursorState
[]
|
null
):
void
;
reveal
(
source
:
string
|
null
|
undefined
,
horizontal
:
boolean
,
target
:
RevealTarget
,
scrollType
:
ScrollType
):
void
;
revealRange
(
source
:
string
|
null
|
undefined
,
revealHorizontal
:
boolean
,
viewRange
:
Range
,
verticalType
:
VerticalRevealType
,
scrollType
:
ScrollType
):
void
;
getPrevEditOperationType
():
EditOperationType
;
setPrevEditOperationType
(
type
:
EditOperationType
):
void
;
}
...
...
src/vs/editor/common/viewModel/viewModel.ts
浏览文件 @
993c1595
...
...
@@ -10,11 +10,12 @@ import { IPosition, Position } from 'vs/editor/common/core/position';
import
{
IRange
,
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
INewScrollPosition
,
ScrollType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
EndOfLinePreference
,
IActiveIndentGuideInfo
,
IModelDecorationOptions
,
TextModelResolvedOptions
}
from
'
vs/editor/common/model
'
;
import
{
IViewEventEmitter
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
IViewEventEmitter
,
VerticalRevealType
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
IPartialViewLinesViewportData
}
from
'
vs/editor/common/viewLayout/viewLinesViewportData
'
;
import
{
IEditorWhitespace
,
IWhitespaceChangeAccessor
}
from
'
vs/editor/common/viewLayout/linesLayout
'
;
import
{
EditorTheme
}
from
'
vs/editor/common/view/viewContext
'
;
import
{
ICursorSimpleModel
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
ICursorSimpleModel
,
PartialCursorState
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
CursorChangeReason
}
from
'
vs/editor/common/controller/cursorEvents
'
;
export
interface
IViewWhitespaceViewportData
{
readonly
id
:
string
;
...
...
@@ -137,6 +138,16 @@ export interface IViewModel extends IViewEventEmitter, ICursorSimpleModel {
getEOL
():
string
;
getPlainTextToCopy
(
modelRanges
:
Range
[],
emptySelectionClipboard
:
boolean
,
forceCRLF
:
boolean
):
string
|
string
[];
getRichTextToCopy
(
modelRanges
:
Range
[],
emptySelectionClipboard
:
boolean
):
{
html
:
string
,
mode
:
string
}
|
null
;
//#region cursor
setCursorStates
(
source
:
string
|
null
|
undefined
,
reason
:
CursorChangeReason
,
states
:
PartialCursorState
[]
|
null
):
void
;
revealPrimary
(
source
:
string
|
null
|
undefined
,
revealHorizontal
:
boolean
):
void
;
revealTopMostCursor
(
source
:
string
|
null
|
undefined
):
void
;
revealBottomMostCursor
(
source
:
string
|
null
|
undefined
):
void
;
revealRange
(
source
:
string
|
null
|
undefined
,
revealHorizontal
:
boolean
,
viewRange
:
Range
,
verticalType
:
VerticalRevealType
,
scrollType
:
ScrollType
):
void
;
//#endregion
}
export
class
MinimapLinesRenderingData
{
...
...
src/vs/editor/common/viewModel/viewModelImpl.ts
浏览文件 @
993c1595
...
...
@@ -26,7 +26,8 @@ import { RunOnceScheduler } from 'vs/base/common/async';
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
EditorTheme
}
from
'
vs/editor/common/view/viewContext
'
;
import
{
Cursor
}
from
'
vs/editor/common/controller/cursor
'
;
import
{
ICursors
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
ICursors
,
PartialCursorState
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
CursorChangeReason
}
from
'
vs/editor/common/controller/cursorEvents
'
;
const
USE_IDENTITY_LINES_COLLECTION
=
true
;
...
...
@@ -93,16 +94,6 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this
.
coordinatesConverter
=
this
.
lines
.
createCoordinatesConverter
();
this
.
cursor
=
this
.
_register
(
new
Cursor
(
this
.
configuration
,
model
,
this
,
this
.
coordinatesConverter
));
this
.
_register
(
this
.
cursor
.
addViewEventListener
((
events
)
=>
{
try
{
const
eventsCollector
=
this
.
_beginEmitViewEvents
();
for
(
const
event
of
events
)
{
eventsCollector
.
emit
(
event
);
}
}
finally
{
this
.
_endEmitViewEvents
();
}
}));
this
.
viewLayout
=
this
.
_register
(
new
ViewLayout
(
this
.
configuration
,
this
.
getLineCount
(),
scheduleAtNextAnimationFrame
));
...
...
@@ -183,7 +174,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
this
.
cursor
.
onLineMappingChanged
();
this
.
cursor
.
onLineMappingChanged
(
eventsCollector
);
this
.
decorations
.
onLineMappingChanged
();
this
.
viewLayout
.
onFlushed
(
this
.
getLineCount
());
...
...
@@ -307,7 +298,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
if
(
!
hadOtherModelChange
&&
hadModelLineChangeThatChangedLineMapping
)
{
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
this
.
cursor
.
onLineMappingChanged
();
this
.
cursor
.
onLineMappingChanged
(
eventsCollector
);
this
.
decorations
.
onLineMappingChanged
();
}
}
finally
{
...
...
@@ -329,7 +320,12 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
}
}
this
.
cursor
.
onModelContentChanged
(
e
);
try
{
const
eventsCollector
=
this
.
_beginEmitViewEvents
();
this
.
cursor
.
onModelContentChanged
(
eventsCollector
,
e
);
}
finally
{
this
.
_endEmitViewEvents
();
}
}));
this
.
_register
(
this
.
model
.
onDidChangeTokens
((
e
)
=>
{
...
...
@@ -362,14 +358,14 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
this
.
_register
(
this
.
model
.
onDidChangeOptions
((
e
)
=>
{
// A tab size change causes a line mapping changed event => all view parts will repaint OK, no further event needed here
if
(
this
.
lines
.
setTabSize
(
this
.
model
.
getOptions
().
tabSize
))
{
this
.
cursor
.
onLineMappingChanged
();
this
.
decorations
.
onLineMappingChanged
();
this
.
viewLayout
.
onFlushed
(
this
.
getLineCount
());
try
{
const
eventsCollector
=
this
.
_beginEmitViewEvents
();
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
this
.
cursor
.
onLineMappingChanged
(
eventsCollector
);
this
.
decorations
.
onLineMappingChanged
();
this
.
viewLayout
.
onFlushed
(
this
.
getLineCount
());
}
finally
{
this
.
_endEmitViewEvents
();
}
...
...
@@ -393,7 +389,7 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
eventsCollector
.
emit
(
new
viewEvents
.
ViewFlushedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewLineMappingChangedEvent
());
eventsCollector
.
emit
(
new
viewEvents
.
ViewDecorationsChangedEvent
(
null
));
this
.
cursor
.
onLineMappingChanged
();
this
.
cursor
.
onLineMappingChanged
(
eventsCollector
);
this
.
decorations
.
onLineMappingChanged
();
this
.
viewLayout
.
onFlushed
(
this
.
getLineCount
());
this
.
viewLayout
.
onHeightMaybeChanged
();
...
...
@@ -845,42 +841,70 @@ export class ViewModel extends viewEvents.ViewEventEmitter implements IViewModel
return
this
.
cursor
.
getPrimaryCursor
().
modelState
.
position
;
}
public
setSelections
(
source
:
string
|
null
|
undefined
,
selections
:
readonly
ISelection
[]):
void
{
this
.
cursor
.
setSelections
(
source
,
selections
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
this
.
cursor
.
setSelections
(
eventsCollector
,
source
,
selections
));
}
public
setCursorStates
(
source
:
string
|
null
|
undefined
,
reason
:
CursorChangeReason
,
states
:
PartialCursorState
[]
|
null
):
void
{
this
.
_withViewEventsCollector
(
eventsCollector
=>
this
.
cursor
.
setStates
(
eventsCollector
,
source
,
reason
,
states
));
}
public
saveCursorState
():
ICursorState
[]
{
return
this
.
cursor
.
saveState
();
}
public
restoreCursorState
(
states
:
ICursorState
[]):
void
{
this
.
cursor
.
restoreState
(
states
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
this
.
cursor
.
restoreState
(
eventsCollector
,
states
)
);
}
public
executeEdits
(
source
:
string
|
null
|
undefined
,
edits
:
IIdentifiedSingleEditOperation
[],
cursorStateComputer
:
ICursorStateComputer
):
void
{
this
.
cursor
.
executeEdits
(
source
,
edits
,
cursorStateComputer
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
this
.
cursor
.
executeEdits
(
eventsCollector
,
source
,
edits
,
cursorStateComputer
)
);
}
public
startComposition
():
void
{
this
.
cursor
.
startComposition
(
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
this
.
cursor
.
startComposition
(
eventsCollector
)
);
}
public
endComposition
(
source
?:
string
|
null
|
undefined
):
void
{
this
.
cursor
.
endComposition
(
source
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
this
.
cursor
.
endComposition
(
eventsCollector
,
source
)
);
}
public
type
(
text
:
string
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
cursor
.
type
(
text
,
source
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
this
.
cursor
.
type
(
eventsCollector
,
text
,
source
)
);
}
public
replacePreviousChar
(
text
:
string
,
replaceCharCnt
:
number
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
cursor
.
replacePreviousChar
(
text
,
replaceCharCnt
,
source
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
this
.
cursor
.
replacePreviousChar
(
eventsCollector
,
text
,
replaceCharCnt
,
source
)
);
}
public
paste
(
text
:
string
,
pasteOnNewLine
:
boolean
,
multicursorText
?:
string
[]
|
null
|
undefined
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
cursor
.
paste
(
text
,
pasteOnNewLine
,
multicursorText
,
source
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
this
.
cursor
.
paste
(
eventsCollector
,
text
,
pasteOnNewLine
,
multicursorText
,
source
)
);
}
public
cut
(
source
?:
string
|
null
|
undefined
):
void
{
this
.
cursor
.
cut
(
source
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
this
.
cursor
.
cut
(
eventsCollector
,
source
)
);
}
public
executeCommand
(
command
:
ICommand
,
source
?:
string
|
null
|
undefined
):
void
{
this
.
cursor
.
executeCommand
(
command
,
source
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
this
.
cursor
.
executeCommand
(
eventsCollector
,
command
,
source
)
);
}
public
executeCommands
(
commands
:
ICommand
[],
source
?:
string
|
null
|
undefined
):
void
{
this
.
cursor
.
executeCommands
(
commands
,
source
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
this
.
cursor
.
executeCommands
(
eventsCollector
,
commands
,
source
));
}
public
revealPrimary
(
source
:
string
|
null
|
undefined
,
revealHorizontal
:
boolean
):
void
{
this
.
_withViewEventsCollector
(
eventsCollector
=>
this
.
cursor
.
revealPrimary
(
eventsCollector
,
source
,
revealHorizontal
,
ScrollType
.
Smooth
));
}
public
revealTopMostCursor
(
source
:
string
|
null
|
undefined
):
void
{
const
viewPosition
=
this
.
cursor
.
getTopMostViewPosition
();
const
viewRange
=
new
Range
(
viewPosition
.
lineNumber
,
viewPosition
.
column
,
viewPosition
.
lineNumber
,
viewPosition
.
column
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
eventsCollector
.
emit
(
new
viewEvents
.
ViewRevealRangeRequestEvent
(
source
,
viewRange
,
null
,
viewEvents
.
VerticalRevealType
.
Simple
,
true
,
ScrollType
.
Smooth
)));
}
public
revealBottomMostCursor
(
source
:
string
|
null
|
undefined
):
void
{
const
viewPosition
=
this
.
cursor
.
getBottomMostViewPosition
();
const
viewRange
=
new
Range
(
viewPosition
.
lineNumber
,
viewPosition
.
column
,
viewPosition
.
lineNumber
,
viewPosition
.
column
);
this
.
_withViewEventsCollector
(
eventsCollector
=>
eventsCollector
.
emit
(
new
viewEvents
.
ViewRevealRangeRequestEvent
(
source
,
viewRange
,
null
,
viewEvents
.
VerticalRevealType
.
Simple
,
true
,
ScrollType
.
Smooth
)));
}
public
revealRange
(
source
:
string
|
null
|
undefined
,
revealHorizontal
:
boolean
,
viewRange
:
Range
,
verticalType
:
viewEvents
.
VerticalRevealType
,
scrollType
:
ScrollType
):
void
{
this
.
_withViewEventsCollector
(
eventsCollector
=>
eventsCollector
.
emit
(
new
viewEvents
.
ViewRevealRangeRequestEvent
(
source
,
viewRange
,
null
,
verticalType
,
revealHorizontal
,
scrollType
)));
}
//#endregion
private
_withViewEventsCollector
(
callback
:
(
eventsCollector
:
viewEvents
.
ViewEventsCollector
)
=>
void
):
void
{
try
{
const
eventsCollector
=
this
.
_beginEmitViewEvents
();
callback
(
eventsCollector
);
}
finally
{
this
.
_endEmitViewEvents
();
}
}
}
src/vs/editor/contrib/multicursor/multicursor.ts
浏览文件 @
993c1595
...
...
@@ -9,7 +9,6 @@ import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import
{
Disposable
,
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
EditorAction
,
ServicesAccessor
,
registerEditorAction
,
registerEditorContribution
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
RevealTarget
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
CursorChangeReason
,
ICursorSelectionChangedEvent
}
from
'
vs/editor/common/controller/cursorEvents
'
;
import
{
CursorMoveCommands
}
from
'
vs/editor/common/controller/cursorMoveCommands
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
...
...
@@ -61,6 +60,7 @@ export class InsertCursorAbove extends EditorAction {
}
const
useLogicalLine
=
(
args
&&
args
.
logicalLine
===
true
);
const
viewModel
=
editor
.
_getViewModel
();
const
cursors
=
editor
.
_getCursors
();
const
context
=
cursors
.
context
;
...
...
@@ -69,12 +69,12 @@ export class InsertCursorAbove extends EditorAction {
}
context
.
model
.
pushStackElement
();
cursors
.
set
States
(
viewModel
.
setCursor
States
(
args
.
source
,
CursorChangeReason
.
Explicit
,
CursorMoveCommands
.
addCursorUp
(
context
,
cursors
.
getAll
(),
useLogicalLine
)
);
cursors
.
reveal
(
args
.
source
,
true
,
RevealTarget
.
TopMost
,
ScrollType
.
Smooth
);
viewModel
.
revealTopMostCursor
(
args
.
source
);
}
}
...
...
@@ -110,6 +110,7 @@ export class InsertCursorBelow extends EditorAction {
}
const
useLogicalLine
=
(
args
&&
args
.
logicalLine
===
true
);
const
viewModel
=
editor
.
_getViewModel
();
const
cursors
=
editor
.
_getCursors
();
const
context
=
cursors
.
context
;
...
...
@@ -118,12 +119,12 @@ export class InsertCursorBelow extends EditorAction {
}
context
.
model
.
pushStackElement
();
cursors
.
set
States
(
viewModel
.
setCursor
States
(
args
.
source
,
CursorChangeReason
.
Explicit
,
CursorMoveCommands
.
addCursorDown
(
context
,
cursors
.
getAll
(),
useLogicalLine
)
);
cursors
.
reveal
(
args
.
source
,
true
,
RevealTarget
.
BottomMost
,
ScrollType
.
Smooth
);
viewModel
.
revealBottomMostCursor
(
args
.
source
);
}
}
...
...
src/vs/editor/contrib/wordOperations/wordOperations.ts
浏览文件 @
993c1595
...
...
@@ -53,7 +53,7 @@ export abstract class MoveWordCommand extends EditorCommand {
});
model
.
pushStackElement
();
editor
.
_get
Cursors
().
set
States
(
'
moveWordCommand
'
,
CursorChangeReason
.
NotSet
,
result
.
map
(
r
=>
CursorState
.
fromModelSelection
(
r
)));
editor
.
_get
ViewModel
().
setCursor
States
(
'
moveWordCommand
'
,
CursorChangeReason
.
NotSet
,
result
.
map
(
r
=>
CursorState
.
fromModelSelection
(
r
)));
if
(
result
.
length
===
1
)
{
const
pos
=
new
Position
(
result
[
0
].
positionLineNumber
,
result
[
0
].
positionColumn
);
editor
.
revealPosition
(
pos
,
ScrollType
.
Smooth
);
...
...
src/vs/editor/test/browser/controller/cursor.test.ts
浏览文件 @
993c1595
此差异已折叠。
点击以展开。
src/vs/editor/test/browser/controller/cursorMoveCommand.test.ts
浏览文件 @
993c1595
...
...
@@ -30,7 +30,7 @@ suite('Cursor move command test', () => {
test
(
'
move left should move to left character
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
8
);
moveTo
(
editor
,
viewModel
,
1
,
8
);
moveLeft
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
7
);
});
...
...
@@ -38,7 +38,7 @@ suite('Cursor move command test', () => {
test
(
'
move left should move to left by n characters
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
8
);
moveTo
(
editor
,
viewModel
,
1
,
8
);
moveLeft
(
editor
,
viewModel
,
3
);
cursorEqual
(
viewModel
,
1
,
5
);
});
...
...
@@ -46,7 +46,7 @@ suite('Cursor move command test', () => {
test
(
'
move left should move to left by half line
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
8
);
moveTo
(
editor
,
viewModel
,
1
,
8
);
moveLeft
(
editor
,
viewModel
,
1
,
CursorMove
.
RawUnit
.
HalfLine
);
cursorEqual
(
viewModel
,
1
,
1
);
});
...
...
@@ -54,7 +54,7 @@ suite('Cursor move command test', () => {
test
(
'
move left moves to previous line
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
2
,
3
);
moveTo
(
editor
,
viewModel
,
2
,
3
);
moveLeft
(
editor
,
viewModel
,
10
);
cursorEqual
(
viewModel
,
1
,
21
);
});
...
...
@@ -62,7 +62,7 @@ suite('Cursor move command test', () => {
test
(
'
move right should move to right character
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
5
);
moveTo
(
editor
,
viewModel
,
1
,
5
);
moveRight
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
6
);
});
...
...
@@ -70,7 +70,7 @@ suite('Cursor move command test', () => {
test
(
'
move right should move to right by n characters
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
2
);
moveTo
(
editor
,
viewModel
,
1
,
2
);
moveRight
(
editor
,
viewModel
,
6
);
cursorEqual
(
viewModel
,
1
,
8
);
});
...
...
@@ -78,7 +78,7 @@ suite('Cursor move command test', () => {
test
(
'
move right should move to right by half line
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
4
);
moveTo
(
editor
,
viewModel
,
1
,
4
);
moveRight
(
editor
,
viewModel
,
1
,
CursorMove
.
RawUnit
.
HalfLine
);
cursorEqual
(
viewModel
,
1
,
14
);
});
...
...
@@ -86,7 +86,7 @@ suite('Cursor move command test', () => {
test
(
'
move right moves to next line
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
8
);
moveTo
(
editor
,
viewModel
,
1
,
8
);
moveRight
(
editor
,
viewModel
,
100
);
cursorEqual
(
viewModel
,
2
,
1
);
});
...
...
@@ -94,7 +94,7 @@ suite('Cursor move command test', () => {
test
(
'
move to first character of line from middle
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
8
);
moveTo
(
editor
,
viewModel
,
1
,
8
);
moveToLineStart
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
1
);
});
...
...
@@ -102,7 +102,7 @@ suite('Cursor move command test', () => {
test
(
'
move to first character of line from first non white space character
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
6
);
moveTo
(
editor
,
viewModel
,
1
,
6
);
moveToLineStart
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
1
);
});
...
...
@@ -110,7 +110,7 @@ suite('Cursor move command test', () => {
test
(
'
move to first character of line from first character
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
1
);
moveTo
(
editor
,
viewModel
,
1
,
1
);
moveToLineStart
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
1
);
});
...
...
@@ -118,7 +118,7 @@ suite('Cursor move command test', () => {
test
(
'
move to first non white space character of line from middle
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
8
);
moveTo
(
editor
,
viewModel
,
1
,
8
);
moveToLineFirstNonWhitespaceCharacter
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
6
);
});
...
...
@@ -126,7 +126,7 @@ suite('Cursor move command test', () => {
test
(
'
move to first non white space character of line from first non white space character
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
6
);
moveTo
(
editor
,
viewModel
,
1
,
6
);
moveToLineFirstNonWhitespaceCharacter
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
6
);
});
...
...
@@ -134,7 +134,7 @@ suite('Cursor move command test', () => {
test
(
'
move to first non white space character of line from first character
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
1
);
moveTo
(
editor
,
viewModel
,
1
,
1
);
moveToLineFirstNonWhitespaceCharacter
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
6
);
});
...
...
@@ -142,7 +142,7 @@ suite('Cursor move command test', () => {
test
(
'
move to end of line from middle
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
8
);
moveTo
(
editor
,
viewModel
,
1
,
8
);
moveToLineEnd
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
21
);
});
...
...
@@ -150,7 +150,7 @@ suite('Cursor move command test', () => {
test
(
'
move to end of line from last non white space character
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
19
);
moveTo
(
editor
,
viewModel
,
1
,
19
);
moveToLineEnd
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
21
);
});
...
...
@@ -158,7 +158,7 @@ suite('Cursor move command test', () => {
test
(
'
move to end of line from line end
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
21
);
moveTo
(
editor
,
viewModel
,
1
,
21
);
moveToLineEnd
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
21
);
});
...
...
@@ -166,7 +166,7 @@ suite('Cursor move command test', () => {
test
(
'
move to last non white space character from middle
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
8
);
moveTo
(
editor
,
viewModel
,
1
,
8
);
moveToLineLastNonWhitespaceCharacter
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
19
);
});
...
...
@@ -174,7 +174,7 @@ suite('Cursor move command test', () => {
test
(
'
move to last non white space character from last non white space character
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
19
);
moveTo
(
editor
,
viewModel
,
1
,
19
);
moveToLineLastNonWhitespaceCharacter
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
19
);
});
...
...
@@ -182,7 +182,7 @@ suite('Cursor move command test', () => {
test
(
'
move to last non white space character from line end
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
21
);
moveTo
(
editor
,
viewModel
,
1
,
21
);
moveToLineLastNonWhitespaceCharacter
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
19
);
});
...
...
@@ -190,7 +190,7 @@ suite('Cursor move command test', () => {
test
(
'
move to center of line not from center
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
8
);
moveTo
(
editor
,
viewModel
,
1
,
8
);
moveToLineCenter
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
11
);
});
...
...
@@ -198,7 +198,7 @@ suite('Cursor move command test', () => {
test
(
'
move to center of line from center
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
11
);
moveTo
(
editor
,
viewModel
,
1
,
11
);
moveToLineCenter
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
11
);
});
...
...
@@ -222,7 +222,7 @@ suite('Cursor move command test', () => {
test
(
'
move up by cursor move command
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
3
,
5
);
moveTo
(
editor
,
viewModel
,
3
,
5
);
cursorEqual
(
viewModel
,
3
,
5
);
moveUp
(
editor
,
viewModel
,
2
);
...
...
@@ -235,7 +235,7 @@ suite('Cursor move command test', () => {
test
(
'
move up by model line cursor move command
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
3
,
5
);
moveTo
(
editor
,
viewModel
,
3
,
5
);
cursorEqual
(
viewModel
,
3
,
5
);
moveUpByModelLine
(
editor
,
viewModel
,
2
);
...
...
@@ -248,7 +248,7 @@ suite('Cursor move command test', () => {
test
(
'
move down by model line cursor move command
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
3
,
5
);
moveTo
(
editor
,
viewModel
,
3
,
5
);
cursorEqual
(
viewModel
,
3
,
5
);
moveDownByModelLine
(
editor
,
viewModel
,
2
);
...
...
@@ -261,7 +261,7 @@ suite('Cursor move command test', () => {
test
(
'
move up with selection by cursor move command
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
3
,
5
);
moveTo
(
editor
,
viewModel
,
3
,
5
);
cursorEqual
(
viewModel
,
3
,
5
);
moveUp
(
editor
,
viewModel
,
1
,
true
);
...
...
@@ -274,7 +274,7 @@ suite('Cursor move command test', () => {
test
(
'
move up and down with tabs by cursor move command
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveTo
(
viewModel
,
1
,
5
);
moveTo
(
editor
,
viewModel
,
1
,
5
);
cursorEqual
(
viewModel
,
1
,
5
);
moveDown
(
editor
,
viewModel
,
4
);
...
...
@@ -296,10 +296,10 @@ suite('Cursor move command test', () => {
test
(
'
move up and down with end of lines starting from a long one by cursor move command
'
,
()
=>
{
executeTest
((
editor
,
viewModel
)
=>
{
moveToEndOfLine
(
viewModel
);
moveToEndOfLine
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
21
);
moveToEndOfLine
(
viewModel
);
moveToEndOfLine
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
21
);
moveDown
(
editor
,
viewModel
,
2
);
...
...
@@ -320,7 +320,7 @@ suite('Cursor move command test', () => {
executeTest
((
editor
,
viewModel
)
=>
{
viewModel
.
getCompletelyVisibleViewRange
=
()
=>
new
Range
(
1
,
1
,
10
,
1
);
moveTo
(
viewModel
,
2
,
2
);
moveTo
(
editor
,
viewModel
,
2
,
2
);
moveToTop
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
1
,
6
);
...
...
@@ -331,7 +331,7 @@ suite('Cursor move command test', () => {
executeTest
((
editor
,
viewModel
)
=>
{
viewModel
.
getCompletelyVisibleViewRange
=
()
=>
new
Range
(
2
,
1
,
10
,
1
);
moveTo
(
viewModel
,
4
,
1
);
moveTo
(
editor
,
viewModel
,
4
,
1
);
moveToTop
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
2
,
2
);
...
...
@@ -342,7 +342,7 @@ suite('Cursor move command test', () => {
executeTest
((
editor
,
viewModel
)
=>
{
viewModel
.
getCompletelyVisibleViewRange
=
()
=>
new
Range
(
1
,
1
,
10
,
1
);
moveTo
(
viewModel
,
4
,
1
);
moveTo
(
editor
,
viewModel
,
4
,
1
);
moveToTop
(
editor
,
viewModel
,
3
);
cursorEqual
(
viewModel
,
3
,
5
);
...
...
@@ -353,7 +353,7 @@ suite('Cursor move command test', () => {
executeTest
((
editor
,
viewModel
)
=>
{
viewModel
.
getCompletelyVisibleViewRange
=
()
=>
new
Range
(
1
,
1
,
3
,
1
);
moveTo
(
viewModel
,
2
,
2
);
moveTo
(
editor
,
viewModel
,
2
,
2
);
moveToTop
(
editor
,
viewModel
,
4
);
cursorEqual
(
viewModel
,
3
,
5
);
...
...
@@ -364,7 +364,7 @@ suite('Cursor move command test', () => {
executeTest
((
editor
,
viewModel
)
=>
{
viewModel
.
getCompletelyVisibleViewRange
=
()
=>
new
Range
(
3
,
1
,
3
,
1
);
moveTo
(
viewModel
,
2
,
2
);
moveTo
(
editor
,
viewModel
,
2
,
2
);
moveToCenter
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
3
,
5
);
...
...
@@ -375,7 +375,7 @@ suite('Cursor move command test', () => {
executeTest
((
editor
,
viewModel
)
=>
{
viewModel
.
getCompletelyVisibleViewRange
=
()
=>
new
Range
(
1
,
1
,
5
,
1
);
moveTo
(
viewModel
,
2
,
2
);
moveTo
(
editor
,
viewModel
,
2
,
2
);
moveToBottom
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
5
,
1
);
...
...
@@ -386,7 +386,7 @@ suite('Cursor move command test', () => {
executeTest
((
editor
,
viewModel
)
=>
{
viewModel
.
getCompletelyVisibleViewRange
=
()
=>
new
Range
(
2
,
1
,
3
,
1
);
moveTo
(
viewModel
,
2
,
2
);
moveTo
(
editor
,
viewModel
,
2
,
2
);
moveToBottom
(
editor
,
viewModel
);
cursorEqual
(
viewModel
,
3
,
5
);
...
...
@@ -397,7 +397,7 @@ suite('Cursor move command test', () => {
executeTest
((
editor
,
viewModel
)
=>
{
viewModel
.
getCompletelyVisibleViewRange
=
()
=>
new
Range
(
1
,
1
,
5
,
1
);
moveTo
(
viewModel
,
4
,
1
);
moveTo
(
editor
,
viewModel
,
4
,
1
);
moveToBottom
(
editor
,
viewModel
,
3
);
cursorEqual
(
viewModel
,
3
,
5
);
...
...
@@ -408,7 +408,7 @@ suite('Cursor move command test', () => {
executeTest
((
editor
,
viewModel
)
=>
{
viewModel
.
getCompletelyVisibleViewRange
=
()
=>
new
Range
(
2
,
1
,
5
,
1
);
moveTo
(
viewModel
,
4
,
1
);
moveTo
(
editor
,
viewModel
,
4
,
1
);
moveToBottom
(
editor
,
viewModel
,
5
);
cursorEqual
(
viewModel
,
2
,
2
);
...
...
@@ -501,22 +501,22 @@ function selectionEqual(selection: Selection, posLineNumber: number, posColumn:
},
'
selection equal
'
);
}
function
moveTo
(
viewModel
:
ViewModel
,
lineNumber
:
number
,
column
:
number
,
inSelectionMode
:
boolean
=
false
)
{
function
moveTo
(
editor
:
ITestCodeEditor
,
viewModel
:
ViewModel
,
lineNumber
:
number
,
column
:
number
,
inSelectionMode
:
boolean
=
false
)
{
if
(
inSelectionMode
)
{
CoreNavigationCommands
.
MoveToSelect
.
runCoreEditorCommand
(
viewModel
.
getCursors
(),
{
CoreNavigationCommands
.
MoveToSelect
.
runCoreEditorCommand
(
editor
,
viewModel
,
viewModel
.
getCursors
(),
{
position
:
new
Position
(
lineNumber
,
column
)
});
}
else
{
CoreNavigationCommands
.
MoveTo
.
runCoreEditorCommand
(
viewModel
.
getCursors
(),
{
CoreNavigationCommands
.
MoveTo
.
runCoreEditorCommand
(
editor
,
viewModel
,
viewModel
.
getCursors
(),
{
position
:
new
Position
(
lineNumber
,
column
)
});
}
}
function
moveToEndOfLine
(
viewModel
:
ViewModel
,
inSelectionMode
:
boolean
=
false
)
{
function
moveToEndOfLine
(
editor
:
ITestCodeEditor
,
viewModel
:
ViewModel
,
inSelectionMode
:
boolean
=
false
)
{
if
(
inSelectionMode
)
{
CoreNavigationCommands
.
CursorEndSelect
.
runCoreEditorCommand
(
viewModel
.
getCursors
(),
{});
CoreNavigationCommands
.
CursorEndSelect
.
runCoreEditorCommand
(
editor
,
viewModel
,
viewModel
.
getCursors
(),
{});
}
else
{
CoreNavigationCommands
.
CursorEnd
.
runCoreEditorCommand
(
viewModel
.
getCursors
(),
{});
CoreNavigationCommands
.
CursorEnd
.
runCoreEditorCommand
(
editor
,
viewModel
,
viewModel
.
getCursors
(),
{});
}
}
src/vs/workbench/contrib/codeEditor/browser/toggleColumnSelection.ts
浏览文件 @
993c1595
...
...
@@ -47,6 +47,7 @@ export class ToggleColumnSelectionAction extends Action {
if
(
!
codeEditor
||
codeEditor
!==
this
.
_getCodeEditor
()
||
oldValue
===
newValue
||
!
codeEditor
.
hasModel
())
{
return
;
}
const
viewModel
=
codeEditor
.
_getViewModel
();
const
cursors
=
codeEditor
.
_getCursors
();
if
(
codeEditor
.
getOption
(
EditorOption
.
columnSelection
))
{
const
selection
=
codeEditor
.
getSelection
();
...
...
@@ -55,12 +56,12 @@ export class ToggleColumnSelectionAction extends Action {
const
modelPosition
=
new
Position
(
selection
.
positionLineNumber
,
selection
.
positionColumn
);
const
viewPosition
=
cursors
.
context
.
coordinatesConverter
.
convertModelPositionToViewPosition
(
modelPosition
);
CoreNavigationCommands
.
MoveTo
.
runCoreEditorCommand
(
cursors
,
{
CoreNavigationCommands
.
MoveTo
.
runCoreEditorCommand
(
c
odeEditor
,
viewModel
,
c
ursors
,
{
position
:
modelSelectionStart
,
viewPosition
:
viewSelectionStart
});
const
visibleColumn
=
CursorColumns
.
visibleColumnFromColumn2
(
cursors
.
context
.
config
,
cursors
.
context
.
viewModel
,
viewPosition
);
CoreNavigationCommands
.
ColumnSelect
.
runCoreEditorCommand
(
cursors
,
{
CoreNavigationCommands
.
ColumnSelect
.
runCoreEditorCommand
(
c
odeEditor
,
viewModel
,
c
ursors
,
{
position
:
modelPosition
,
viewPosition
:
viewPosition
,
doColumnSelect
:
true
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录