Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
cca161bd
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,发现更多精彩内容 >>
提交
cca161bd
编写于
3月 26, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up in cursor
上级
3a093b39
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
573 addition
and
579 deletion
+573
-579
src/vs/editor/common/controller/cursor.ts
src/vs/editor/common/controller/cursor.ts
+157
-92
src/vs/editor/common/controller/cursorCollection.ts
src/vs/editor/common/controller/cursorCollection.ts
+37
-12
src/vs/editor/common/controller/cursorCommon.ts
src/vs/editor/common/controller/cursorCommon.ts
+17
-42
src/vs/editor/common/controller/cursorMoveOperations.ts
src/vs/editor/common/controller/cursorMoveOperations.ts
+20
-51
src/vs/editor/common/controller/cursorTypeOperations.ts
src/vs/editor/common/controller/cursorTypeOperations.ts
+5
-9
src/vs/editor/common/controller/cursorWordOperations.ts
src/vs/editor/common/controller/cursorWordOperations.ts
+6
-11
src/vs/editor/common/controller/oneCursor.ts
src/vs/editor/common/controller/oneCursor.ts
+331
-362
未找到文件。
src/vs/editor/common/controller/cursor.ts
浏览文件 @
cca161bd
此差异已折叠。
点击以展开。
src/vs/editor/common/controller/cursorCollection.ts
浏览文件 @
cca161bd
...
...
@@ -11,6 +11,7 @@ import { IConfiguration, IModel, ISelection } from 'vs/editor/common/editorCommo
import
{
IAutoClosingPair
}
from
'
vs/editor/common/modes/languageConfiguration
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
CursorState
}
from
'
vs/editor/common/controller/cursorCommon
'
;
export
interface
ICursorCollectionState
{
primary
:
IOneCursorState
;
...
...
@@ -150,6 +151,42 @@ export class CursorCollection {
this
.
_setSecondarySelections
(
selections
.
slice
(
1
),
viewSelections
?
viewSelections
.
slice
(
1
)
:
null
);
}
public
getPrimaryCursor
():
OneCursor
{
return
this
.
primaryCursor
;
}
public
setStates
(
states
:
CursorState
[],
ensureInEditableRange
:
boolean
):
void
{
if
(
states
===
null
)
{
return
;
}
this
.
primaryCursor
.
setState
(
states
[
0
].
modelState
,
states
[
0
].
viewState
,
ensureInEditableRange
);
this
.
_setSecondaryStates
(
states
.
slice
(
1
),
ensureInEditableRange
);
}
/**
* Creates or disposes secondary cursors as necessary to match the number of `secondarySelections`.
*/
private
_setSecondaryStates
(
secondaryStates
:
CursorState
[],
ensureInEditableRange
:
boolean
):
void
{
const
secondaryCursorsLength
=
this
.
secondaryCursors
.
length
;
const
secondaryStatesLength
=
secondaryStates
.
length
;
if
(
secondaryCursorsLength
<
secondaryStatesLength
)
{
let
createCnt
=
secondaryStatesLength
-
secondaryCursorsLength
;
for
(
let
i
=
0
;
i
<
createCnt
;
i
++
)
{
this
.
addSecondaryCursor
(
null
);
}
}
else
if
(
secondaryCursorsLength
>
secondaryStatesLength
)
{
let
removeCnt
=
secondaryCursorsLength
-
secondaryStatesLength
;
for
(
let
i
=
0
;
i
<
removeCnt
;
i
++
)
{
this
.
_removeSecondaryCursor
(
this
.
secondaryCursors
.
length
-
1
);
}
}
for
(
let
i
=
0
;
i
<
secondaryStatesLength
;
i
++
)
{
this
.
secondaryCursors
[
i
].
setState
(
secondaryStates
[
i
].
modelState
,
secondaryStates
[
i
].
viewState
,
ensureInEditableRange
);
}
}
public
killSecondaryCursors
():
boolean
{
return
(
this
.
_setSecondarySelections
([],
[])
>
0
);
}
...
...
@@ -167,18 +204,6 @@ export class CursorCollection {
this
.
lastAddedCursorIndex
=
this
.
secondaryCursors
.
length
;
}
public
duplicateCursors
():
void
{
var
newCursors
:
OneCursor
[]
=
[];
newCursors
.
push
(
this
.
primaryCursor
.
duplicate
());
for
(
var
i
=
0
,
len
=
this
.
secondaryCursors
.
length
;
i
<
len
;
i
++
)
{
newCursors
.
push
(
this
.
secondaryCursors
[
i
].
duplicate
());
}
this
.
secondaryCursors
=
this
.
secondaryCursors
.
concat
(
newCursors
);
this
.
lastAddedCursorIndex
=
this
.
secondaryCursors
.
length
;
}
public
getLastAddedCursor
():
OneCursor
{
if
(
this
.
secondaryCursors
.
length
===
0
||
this
.
lastAddedCursorIndex
===
0
)
{
return
this
.
primaryCursor
;
...
...
src/vs/editor/common/controller/cursorCommon.ts
浏览文件 @
cca161bd
...
...
@@ -8,7 +8,7 @@ import { Position } from 'vs/editor/common/core/position';
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
IModeConfiguration
}
from
'
vs/editor/common/controller/oneCursor
'
;
import
{
ICommand
,
CursorChangeReason
,
IConfigurationChangedEvent
,
TextModelResolvedOptions
,
IConfiguration
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommand
,
IConfigurationChangedEvent
,
TextModelResolvedOptions
,
IConfiguration
}
from
'
vs/editor/common/editorCommon
'
;
import
{
TextModel
}
from
'
vs/editor/common/model/textModel
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
...
...
@@ -118,48 +118,21 @@ export class SingleCursorState {
return
(
!
this
.
selection
.
isEmpty
()
||
!
this
.
selectionStart
.
isEmpty
());
}
public
withSelectionStartLeftoverVisibleColumns
(
selectionStartLeftoverVisibleColumns
:
number
):
SingleCursorState
{
return
new
SingleCursorState
(
this
.
selectionStart
,
selectionStartLeftoverVisibleColumns
,
this
.
position
,
this
.
leftoverVisibleColumns
);
}
public
withSelectionStart
(
selectionStart
:
Range
):
SingleCursorState
{
return
new
SingleCursorState
(
selectionStart
,
0
,
this
.
position
,
this
.
leftoverVisibleColumns
);
}
public
collapse
():
SingleCursorState
{
return
new
SingleCursorState
(
new
Range
(
this
.
position
.
lineNumber
,
this
.
position
.
column
,
this
.
position
.
lineNumber
,
this
.
position
.
column
),
0
,
this
.
position
,
0
);
}
public
move
(
inSelectionMode
:
boolean
,
position
:
Position
,
leftoverVisibleColumns
:
number
):
SingleCursorState
{
public
move
(
inSelectionMode
:
boolean
,
lineNumber
:
number
,
column
:
number
,
leftoverVisibleColumns
:
number
):
SingleCursorState
{
if
(
inSelectionMode
)
{
// move just position
return
new
SingleCursorState
(
this
.
selectionStart
,
this
.
selectionStartLeftoverVisibleColumns
,
position
,
new
Position
(
lineNumber
,
column
)
,
leftoverVisibleColumns
);
}
else
{
// move everything
return
new
SingleCursorState
(
new
Range
(
position
.
lineNumber
,
position
.
column
,
position
.
lineNumber
,
position
.
column
),
new
Range
(
lineNumber
,
column
,
lineNumber
,
column
),
leftoverVisibleColumns
,
position
,
new
Position
(
lineNumber
,
column
)
,
leftoverVisibleColumns
);
}
...
...
@@ -194,6 +167,18 @@ export class SingleCursorState {
}
}
export
class
CursorState
{
_cursorStateBrand
:
void
;
readonly
modelState
:
SingleCursorState
;
readonly
viewState
:
SingleCursorState
;
constructor
(
modelState
:
SingleCursorState
,
viewState
:
SingleCursorState
)
{
this
.
modelState
=
modelState
;
this
.
viewState
=
viewState
;
}
}
export
class
EditOperationResult
{
_editOperationBrand
:
void
;
...
...
@@ -202,7 +187,6 @@ export class EditOperationResult {
readonly
shouldPushStackElementAfter
:
boolean
;
readonly
isAutoWhitespaceCommand
:
boolean
;
readonly
shouldRevealHorizontal
:
boolean
;
readonly
cursorPositionChangeReason
:
CursorChangeReason
;
constructor
(
command
:
ICommand
,
...
...
@@ -210,8 +194,6 @@ export class EditOperationResult {
shouldPushStackElementBefore
:
boolean
;
shouldPushStackElementAfter
:
boolean
;
isAutoWhitespaceCommand
?:
boolean
;
shouldRevealHorizontal
?:
boolean
;
cursorPositionChangeReason
?:
CursorChangeReason
;
}
)
{
this
.
command
=
command
;
...
...
@@ -219,17 +201,10 @@ export class EditOperationResult {
this
.
shouldPushStackElementAfter
=
opts
.
shouldPushStackElementAfter
;
this
.
isAutoWhitespaceCommand
=
false
;
this
.
shouldRevealHorizontal
=
true
;
this
.
cursorPositionChangeReason
=
CursorChangeReason
.
NotSet
;
if
(
typeof
opts
.
isAutoWhitespaceCommand
!==
'
undefined
'
)
{
this
.
isAutoWhitespaceCommand
=
opts
.
isAutoWhitespaceCommand
;
}
if
(
typeof
opts
.
shouldRevealHorizontal
!==
'
undefined
'
)
{
this
.
shouldRevealHorizontal
=
opts
.
shouldRevealHorizontal
;
}
if
(
typeof
opts
.
cursorPositionChangeReason
!==
'
undefined
'
)
{
this
.
cursorPositionChangeReason
=
opts
.
cursorPositionChangeReason
;
}
}
}
...
...
src/vs/editor/common/controller/cursorMoveOperations.ts
浏览文件 @
cca161bd
...
...
@@ -5,7 +5,6 @@
'
use strict
'
;
import
{
SingleCursorState
,
CursorColumns
,
CursorConfiguration
,
ICursorSimpleModel
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
CursorChangeReason
}
from
'
vs/editor/common/editorCommon
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
...
...
@@ -23,32 +22,6 @@ export class CursorPosition {
}
}
export
class
SingleMoveOperationResult
{
_singleMoveOperationBrand
:
void
;
public
static
fromMove
(
initialState
:
SingleCursorState
,
inSelectionMode
:
boolean
,
lineNumber
:
number
,
column
:
number
,
leftoverVisibleColumns
:
number
,
ensureInEditableRange
:
boolean
,
reason
:
CursorChangeReason
):
SingleMoveOperationResult
{
return
new
SingleMoveOperationResult
(
initialState
.
move
(
inSelectionMode
,
new
Position
(
lineNumber
,
column
),
leftoverVisibleColumns
),
ensureInEditableRange
,
reason
);
}
readonly
state
:
SingleCursorState
;
readonly
ensureInEditableRange
:
boolean
;
readonly
reason
:
CursorChangeReason
;
constructor
(
state
:
SingleCursorState
,
ensureInEditableRange
:
boolean
,
reason
:
CursorChangeReason
)
{
this
.
state
=
state
;
this
.
ensureInEditableRange
=
ensureInEditableRange
;
this
.
reason
=
reason
;
}
}
export
class
MoveOperations
{
public
static
left
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
lineNumber
:
number
,
column
:
number
):
CursorPosition
{
...
...
@@ -68,7 +41,7 @@ export class MoveOperations {
return
new
CursorPosition
(
lineNumber
,
column
,
0
);
}
public
static
moveLeft
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
,
noOfColumns
:
number
):
Single
MoveOperationResult
{
public
static
moveLeft
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
,
noOfColumns
:
number
):
Single
CursorState
{
let
lineNumber
:
number
,
column
:
number
;
...
...
@@ -82,7 +55,7 @@ export class MoveOperations {
column
=
r
.
column
;
}
return
SingleMoveOperationResult
.
fromMove
(
cursor
,
inSelectionMode
,
lineNumber
,
column
,
0
,
true
,
CursorChangeReason
.
Explicit
);
return
cursor
.
move
(
inSelectionMode
,
lineNumber
,
column
,
0
);
}
public
static
right
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
lineNumber
:
number
,
column
:
number
):
CursorPosition
{
...
...
@@ -102,7 +75,7 @@ export class MoveOperations {
return
new
CursorPosition
(
lineNumber
,
column
,
0
);
}
public
static
moveRight
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
,
noOfColumns
:
number
):
Single
MoveOperationResult
{
public
static
moveRight
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
,
noOfColumns
:
number
):
Single
CursorState
{
let
lineNumber
:
number
,
column
:
number
;
...
...
@@ -116,7 +89,7 @@ export class MoveOperations {
column
=
r
.
column
;
}
return
SingleMoveOperationResult
.
fromMove
(
cursor
,
inSelectionMode
,
lineNumber
,
column
,
0
,
true
,
CursorChangeReason
.
Explicit
);
return
cursor
.
move
(
inSelectionMode
,
lineNumber
,
column
,
0
);
}
public
static
down
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
lineNumber
:
number
,
column
:
number
,
leftoverVisibleColumns
:
number
,
count
:
number
,
allowMoveOnLastLine
:
boolean
):
CursorPosition
{
...
...
@@ -146,7 +119,7 @@ export class MoveOperations {
return
new
CursorPosition
(
lineNumber
,
column
,
leftoverVisibleColumns
);
}
public
static
moveDown
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
,
linesCount
:
number
):
Single
MoveOperationResult
{
public
static
moveDown
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
,
linesCount
:
number
):
Single
CursorState
{
let
lineNumber
:
number
,
column
:
number
;
...
...
@@ -161,23 +134,21 @@ export class MoveOperations {
let
r
=
MoveOperations
.
down
(
config
,
model
,
lineNumber
,
column
,
cursor
.
leftoverVisibleColumns
,
linesCount
,
true
);
return
SingleMoveOperationResult
.
fromMove
(
cursor
,
inSelectionMode
,
r
.
lineNumber
,
r
.
column
,
r
.
leftoverVisibleColumns
,
true
,
CursorChangeReason
.
Explicit
);
return
cursor
.
move
(
inSelectionMode
,
r
.
lineNumber
,
r
.
column
,
r
.
leftoverVisibleColumns
);
}
public
static
translateDown
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
):
Single
MoveOperationResult
{
public
static
translateDown
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
):
Single
CursorState
{
let
selection
=
cursor
.
selection
;
let
selectionStart
=
MoveOperations
.
down
(
config
,
model
,
selection
.
selectionStartLineNumber
,
selection
.
selectionStartColumn
,
cursor
.
selectionStartLeftoverVisibleColumns
,
1
,
false
);
let
position
=
MoveOperations
.
down
(
config
,
model
,
selection
.
positionLineNumber
,
selection
.
positionColumn
,
cursor
.
leftoverVisibleColumns
,
1
,
false
);
let
tmp
=
new
SingleCursorState
(
return
new
SingleCursorState
(
new
Range
(
selectionStart
.
lineNumber
,
selectionStart
.
column
,
selectionStart
.
lineNumber
,
selectionStart
.
column
),
selectionStart
.
leftoverVisibleColumns
,
new
Position
(
position
.
lineNumber
,
position
.
column
),
position
.
leftoverVisibleColumns
);
return
new
SingleMoveOperationResult
(
tmp
,
true
,
CursorChangeReason
.
Explicit
);
}
public
static
up
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
lineNumber
:
number
,
column
:
number
,
leftoverVisibleColumns
:
number
,
count
:
number
,
allowMoveOnFirstLine
:
boolean
):
CursorPosition
{
...
...
@@ -206,7 +177,7 @@ export class MoveOperations {
return
new
CursorPosition
(
lineNumber
,
column
,
leftoverVisibleColumns
);
}
public
static
moveUp
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
,
linesCount
:
number
):
Single
MoveOperationResult
{
public
static
moveUp
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
,
linesCount
:
number
):
Single
CursorState
{
let
lineNumber
:
number
,
column
:
number
;
...
...
@@ -221,27 +192,25 @@ export class MoveOperations {
let
r
=
MoveOperations
.
up
(
config
,
model
,
lineNumber
,
column
,
cursor
.
leftoverVisibleColumns
,
linesCount
,
true
);
return
SingleMoveOperationResult
.
fromMove
(
cursor
,
inSelectionMode
,
r
.
lineNumber
,
r
.
column
,
r
.
leftoverVisibleColumns
,
true
,
CursorChangeReason
.
Explicit
);
return
cursor
.
move
(
inSelectionMode
,
r
.
lineNumber
,
r
.
column
,
r
.
leftoverVisibleColumns
);
}
public
static
translateUp
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
):
Single
MoveOperationResult
{
public
static
translateUp
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
):
Single
CursorState
{
let
selection
=
cursor
.
selection
;
let
selectionStart
=
MoveOperations
.
up
(
config
,
model
,
selection
.
selectionStartLineNumber
,
selection
.
selectionStartColumn
,
cursor
.
selectionStartLeftoverVisibleColumns
,
1
,
false
);
let
position
=
MoveOperations
.
up
(
config
,
model
,
selection
.
positionLineNumber
,
selection
.
positionColumn
,
cursor
.
leftoverVisibleColumns
,
1
,
false
);
let
tmp
=
new
SingleCursorState
(
return
new
SingleCursorState
(
new
Range
(
selectionStart
.
lineNumber
,
selectionStart
.
column
,
selectionStart
.
lineNumber
,
selectionStart
.
column
),
selectionStart
.
leftoverVisibleColumns
,
new
Position
(
position
.
lineNumber
,
position
.
column
),
position
.
leftoverVisibleColumns
);
return
new
SingleMoveOperationResult
(
tmp
,
true
,
CursorChangeReason
.
Explicit
);
}
public
static
moveToBeginningOfLine
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
):
Single
MoveOperationResult
{
public
static
moveToBeginningOfLine
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
):
Single
CursorState
{
let
lineNumber
=
cursor
.
position
.
lineNumber
;
let
minColumn
=
model
.
getLineMinColumn
(
lineNumber
);
let
firstNonBlankColumn
=
model
.
getLineFirstNonWhitespaceColumn
(
lineNumber
)
||
minColumn
;
...
...
@@ -255,23 +224,23 @@ export class MoveOperations {
column
=
firstNonBlankColumn
;
}
return
SingleMoveOperationResult
.
fromMove
(
cursor
,
inSelectionMode
,
lineNumber
,
column
,
0
,
true
,
CursorChangeReason
.
Explicit
);
return
cursor
.
move
(
inSelectionMode
,
lineNumber
,
column
,
0
);
}
public
static
moveToEndOfLine
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
):
Single
MoveOperationResult
{
public
static
moveToEndOfLine
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
):
Single
CursorState
{
let
lineNumber
=
cursor
.
position
.
lineNumber
;
let
maxColumn
=
model
.
getLineMaxColumn
(
lineNumber
);
return
SingleMoveOperationResult
.
fromMove
(
cursor
,
inSelectionMode
,
lineNumber
,
maxColumn
,
0
,
true
,
CursorChangeReason
.
Explicit
);
return
cursor
.
move
(
inSelectionMode
,
lineNumber
,
maxColumn
,
0
);
}
public
static
moveToBeginningOfBuffer
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
):
Single
MoveOperationResult
{
return
SingleMoveOperationResult
.
fromMove
(
cursor
,
inSelectionMode
,
1
,
1
,
0
,
true
,
CursorChangeReason
.
Explicit
);
public
static
moveToBeginningOfBuffer
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
):
Single
CursorState
{
return
cursor
.
move
(
inSelectionMode
,
1
,
1
,
0
);
}
public
static
moveToEndOfBuffer
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
):
Single
MoveOperationResult
{
public
static
moveToEndOfBuffer
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
):
Single
CursorState
{
let
lastLineNumber
=
model
.
getLineCount
();
let
lastColumn
=
model
.
getLineMaxColumn
(
lastLineNumber
);
return
SingleMoveOperationResult
.
fromMove
(
cursor
,
inSelectionMode
,
lastLineNumber
,
lastColumn
,
0
,
true
,
CursorChangeReason
.
Explicit
);
return
cursor
.
move
(
inSelectionMode
,
lastLineNumber
,
lastColumn
,
0
);
}
}
src/vs/editor/common/controller/cursorTypeOperations.ts
浏览文件 @
cca161bd
...
...
@@ -8,7 +8,7 @@ import { onUnexpectedError } from 'vs/base/common/errors';
import
{
ReplaceCommand
,
ReplaceCommandWithoutChangingPosition
,
ReplaceCommandWithOffsetCursorState
}
from
'
vs/editor/common/commands/replaceCommand
'
;
import
{
SingleCursorState
,
EditOperationResult
,
CursorColumns
,
CursorConfiguration
,
ICursorSimpleModel
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
CursorChangeReason
,
ICommand
,
ITokenizedModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommand
,
ITokenizedModel
}
from
'
vs/editor/common/editorCommon
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
ShiftCommand
}
from
'
vs/editor/common/commands/shiftCommand
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
...
...
@@ -27,8 +27,7 @@ export class TypeOperations {
oneIndent
:
config
.
oneIndent
}),
{
shouldPushStackElementBefore
:
true
,
shouldPushStackElementAfter
:
true
,
shouldRevealHorizontal
:
false
shouldPushStackElementAfter
:
true
}
);
}
...
...
@@ -41,8 +40,7 @@ export class TypeOperations {
oneIndent
:
config
.
oneIndent
}),
{
shouldPushStackElementBefore
:
true
,
shouldPushStackElementAfter
:
true
,
shouldRevealHorizontal
:
false
shouldPushStackElementAfter
:
true
}
);
}
...
...
@@ -89,15 +87,13 @@ export class TypeOperations {
let
typeSelection
=
new
Range
(
position
.
lineNumber
,
1
,
position
.
lineNumber
,
1
);
return
new
EditOperationResult
(
new
ReplaceCommand
(
typeSelection
,
text
),
{
shouldPushStackElementBefore
:
true
,
shouldPushStackElementAfter
:
true
,
cursorPositionChangeReason
:
CursorChangeReason
.
Paste
shouldPushStackElementAfter
:
true
});
}
return
new
EditOperationResult
(
new
ReplaceCommand
(
selection
,
text
),
{
shouldPushStackElementBefore
:
true
,
shouldPushStackElementAfter
:
true
,
cursorPositionChangeReason
:
CursorChangeReason
.
Paste
shouldPushStackElementAfter
:
true
});
}
...
...
src/vs/editor/common/controller/cursorWordOperations.ts
浏览文件 @
cca161bd
...
...
@@ -8,8 +8,6 @@ import { SingleCursorState, CursorConfiguration, ICursorSimpleModel } from 'vs/e
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
CharCode
}
from
'
vs/base/common/charCode
'
;
import
{
CharacterClassifier
}
from
'
vs/editor/common/core/characterClassifier
'
;
import
{
SingleMoveOperationResult
}
from
'
vs/editor/common/controller/cursorMoveOperations
'
;
import
{
CursorChangeReason
}
from
'
vs/editor/common/editorCommon
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
...
...
@@ -419,7 +417,7 @@ export class WordOperations {
return
new
Range
(
lineNumber
,
column
,
position
.
lineNumber
,
position
.
column
);
}
public
static
word
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
,
position
:
Position
):
Single
MoveOperationResult
{
public
static
word
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
inSelectionMode
:
boolean
,
position
:
Position
):
Single
CursorState
{
const
wordSeparators
=
getMapForWordSeparators
(
config
.
wordSeparators
);
let
prevWord
=
WordOperations
.
_findPreviousWordOnLine
(
wordSeparators
,
model
,
position
);
let
isInPrevWord
=
(
prevWord
&&
prevWord
.
wordType
===
WordType
.
Regular
&&
prevWord
.
start
<
position
.
column
-
1
&&
position
.
column
-
1
<=
prevWord
.
end
);
...
...
@@ -427,6 +425,7 @@ export class WordOperations {
let
isInNextWord
=
(
nextWord
&&
nextWord
.
wordType
===
WordType
.
Regular
&&
nextWord
.
start
<
position
.
column
-
1
&&
position
.
column
-
1
<=
nextWord
.
end
);
if
(
!
inSelectionMode
||
!
cursor
.
hasSelection
())
{
// Entering word selection for the first time
let
startColumn
:
number
;
let
endColumn
:
number
;
...
...
@@ -450,13 +449,9 @@ export class WordOperations {
}
}
return
new
SingleMoveOperationResult
(
new
SingleCursorState
(
new
Range
(
position
.
lineNumber
,
startColumn
,
position
.
lineNumber
,
endColumn
),
0
,
new
Position
(
position
.
lineNumber
,
endColumn
),
0
),
false
,
CursorChangeReason
.
Explicit
return
new
SingleCursorState
(
new
Range
(
position
.
lineNumber
,
startColumn
,
position
.
lineNumber
,
endColumn
),
0
,
new
Position
(
position
.
lineNumber
,
endColumn
),
0
);
}
...
...
@@ -490,6 +485,6 @@ export class WordOperations {
}
}
return
SingleMoveOperationResult
.
fromMove
(
cursor
,
cursor
.
hasSelection
(),
lineNumber
,
column
,
0
,
false
,
CursorChangeReason
.
Explicit
);
return
cursor
.
move
(
cursor
.
hasSelection
(),
lineNumber
,
column
,
0
);
}
}
src/vs/editor/common/controller/oneCursor.ts
浏览文件 @
cca161bd
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录