Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0840d28d
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,发现更多精彩内容 >>
提交
0840d28d
编写于
4月 24, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Begin moving cursor core ops out
上级
0c229e92
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
461 addition
and
325 deletion
+461
-325
src/vs/editor/browser/standalone/standaloneEditor.ts
src/vs/editor/browser/standalone/standaloneEditor.ts
+1
-2
src/vs/editor/browser/view/viewController.ts
src/vs/editor/browser/view/viewController.ts
+3
-2
src/vs/editor/common/commonCodeEditor.ts
src/vs/editor/common/commonCodeEditor.ts
+5
-1
src/vs/editor/common/config/config.ts
src/vs/editor/common/config/config.ts
+197
-2
src/vs/editor/common/controller/coreCommands.ts
src/vs/editor/common/controller/coreCommands.ts
+108
-0
src/vs/editor/common/controller/cursor.ts
src/vs/editor/common/controller/cursor.ts
+70
-213
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+7
-2
src/vs/editor/common/editorCommonExtensions.ts
src/vs/editor/common/editorCommonExtensions.ts
+25
-5
src/vs/editor/contrib/accessibility/browser/accessibility.ts
src/vs/editor/contrib/accessibility/browser/accessibility.ts
+2
-2
src/vs/editor/contrib/find/test/common/findModel.test.ts
src/vs/editor/contrib/find/test/common/findModel.test.ts
+7
-6
src/vs/editor/test/common/controller/cursor.test.ts
src/vs/editor/test/common/controller/cursor.test.ts
+19
-10
src/vs/editor/test/common/controller/cursorMoveCommand.test.ts
...s/editor/test/common/controller/cursorMoveCommand.test.ts
+10
-1
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+0
-75
src/vs/workbench/parts/preferences/browser/preferencesEditor.ts
.../workbench/parts/preferences/browser/preferencesEditor.ts
+5
-3
src/vs/workbench/test/common/editor/rangeDecorations.test.ts
src/vs/workbench/test/common/editor/rangeDecorations.test.ts
+2
-1
未找到文件。
src/vs/editor/browser/standalone/standaloneEditor.ts
浏览文件 @
0840d28d
...
...
@@ -368,7 +368,6 @@ export function createMonacoEditorAPI(): typeof monaco.editor {
FindMatch
:
<
any
>
editorCommon
.
FindMatch
,
// vars
EditorType
:
editorCommon
.
EditorType
,
Handler
:
editorCommon
.
Handler
,
EditorType
:
editorCommon
.
EditorType
};
}
src/vs/editor/browser/view/viewController.ts
浏览文件 @
0840d28d
...
...
@@ -11,6 +11,7 @@ import { IEditorMouseEvent } from 'vs/editor/browser/editorBrowser';
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IViewModel
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
ViewOutgoingEvents
}
from
'
vs/editor/browser/view/viewOutgoingEvents
'
;
import
{
CoreCommands
}
from
"
vs/editor/common/controller/coreCommands
"
;
export
interface
TriggerCursorHandler
{
(
source
:
string
,
handlerId
:
string
,
payload
:
any
):
void
;
...
...
@@ -159,7 +160,7 @@ export class ViewController {
public
moveTo
(
source
:
string
,
viewPosition
:
Position
):
void
{
viewPosition
=
this
.
_validateViewColumn
(
viewPosition
);
this
.
triggerCursorHandler
(
source
,
editorCommon
.
Handler
.
MoveTo
,
{
this
.
triggerCursorHandler
(
source
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
this
.
convertViewToModelPosition
(
viewPosition
),
viewPosition
:
viewPosition
});
...
...
@@ -167,7 +168,7 @@ export class ViewController {
private
moveToSelect
(
source
:
string
,
viewPosition
:
Position
):
void
{
viewPosition
=
this
.
_validateViewColumn
(
viewPosition
);
this
.
triggerCursorHandler
(
source
,
editorCommon
.
Handler
.
MoveToSelect
,
{
this
.
triggerCursorHandler
(
source
,
CoreCommands
.
MoveToSelect
.
id
,
{
position
:
this
.
convertViewToModelPosition
(
viewPosition
),
viewPosition
:
viewPosition
});
...
...
src/vs/editor/common/commonCodeEditor.ts
浏览文件 @
0840d28d
...
...
@@ -13,7 +13,7 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
import
{
IContextKey
,
IContextKeyServiceTarget
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
CommonEditorConfiguration
}
from
'
vs/editor/common/config/commonEditorConfig
'
;
import
{
DefaultConfig
}
from
'
vs/editor/common/config/defaultConfig
'
;
import
{
Cursor
}
from
'
vs/editor/common/controller/cursor
'
;
import
{
Cursor
,
ICursors
}
from
'
vs/editor/common/controller/cursor
'
;
import
{
CursorColumns
,
IViewModelHelper
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
Position
,
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
,
IRange
}
from
'
vs/editor/common/core/range
'
;
...
...
@@ -604,6 +604,10 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo
}
}
public
getCursors
():
ICursors
{
return
this
.
cursor
;
}
public
executeCommand
(
source
:
string
,
command
:
editorCommon
.
ICommand
):
void
{
if
(
!
this
.
cursor
)
{
return
;
...
...
src/vs/editor/common/config/config.ts
浏览文件 @
0840d28d
...
...
@@ -15,12 +15,207 @@ import { ICodeEditorService, getCodeEditor } from 'vs/editor/common/services/cod
import
{
CommandsRegistry
,
ICommandHandler
,
ICommandHandlerDescription
}
from
'
vs/platform/commands/common/commands
'
;
import
{
CursorMove
}
from
"
vs/editor/common/controller/cursorMoveCommands
"
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
EditorScroll
,
RevealLine
}
from
"
vs/editor/common/controller/cursor
"
;
import
*
as
types
from
'
vs/base/common/types
'
;
import
H
=
editorCommon
.
Handler
;
const
CORE_WEIGHT
=
KeybindingsRegistry
.
WEIGHT
.
editorCore
();
export
namespace
EditorScroll
{
const
isEditorScrollArgs
=
function
(
arg
):
boolean
{
if
(
!
types
.
isObject
(
arg
))
{
return
false
;
}
let
scrollArg
:
RawArguments
=
arg
;
if
(
!
types
.
isString
(
scrollArg
.
to
))
{
return
false
;
}
if
(
!
types
.
isUndefined
(
scrollArg
.
by
)
&&
!
types
.
isString
(
scrollArg
.
by
))
{
return
false
;
}
if
(
!
types
.
isUndefined
(
scrollArg
.
value
)
&&
!
types
.
isNumber
(
scrollArg
.
value
))
{
return
false
;
}
if
(
!
types
.
isUndefined
(
scrollArg
.
revealCursor
)
&&
!
types
.
isBoolean
(
scrollArg
.
revealCursor
))
{
return
false
;
}
return
true
;
};
export
const
description
=
<
ICommandHandlerDescription
>
{
description
:
'
Scroll editor in the given direction
'
,
args
:
[
{
name
:
'
Editor scroll argument object
'
,
description
:
`Property-value pairs that can be passed through this argument:
* 'to': A mandatory direction value.
\`\`\`
'up', 'down'
\`\`\`
* 'by': Unit to move. Default is computed based on 'to' value.
\`\`\`
'line', 'wrappedLine', 'page', 'halfPage'
\`\`\`
* 'value': Number of units to move. Default is '1'.
* 'revealCursor': If 'true' reveals the cursor if it is outside view port.
`
,
constraint
:
isEditorScrollArgs
}
]
};
/**
* Directions in the view for editor scroll command.
*/
export
const
RawDirection
=
{
Up
:
'
up
'
,
Down
:
'
down
'
,
};
/**
* Units for editor scroll 'by' argument
*/
export
const
RawUnit
=
{
Line
:
'
line
'
,
WrappedLine
:
'
wrappedLine
'
,
Page
:
'
page
'
,
HalfPage
:
'
halfPage
'
};
/**
* Arguments for editor scroll command
*/
export
interface
RawArguments
{
to
:
string
;
by
?:
string
;
value
?:
number
;
revealCursor
?:
boolean
;
};
export
function
parse
(
args
:
RawArguments
):
ParsedArguments
{
let
direction
:
Direction
;
switch
(
args
.
to
)
{
case
RawDirection
.
Up
:
direction
=
Direction
.
Up
;
break
;
case
RawDirection
.
Down
:
direction
=
Direction
.
Down
;
break
;
default
:
// Illegal arguments
return
null
;
}
let
unit
:
Unit
;
switch
(
args
.
by
)
{
case
RawUnit
.
Line
:
unit
=
Unit
.
Line
;
break
;
case
RawUnit
.
WrappedLine
:
unit
=
Unit
.
WrappedLine
;
break
;
case
RawUnit
.
Page
:
unit
=
Unit
.
Page
;
break
;
case
RawUnit
.
HalfPage
:
unit
=
Unit
.
HalfPage
;
break
;
default
:
unit
=
Unit
.
WrappedLine
;
}
const
value
=
Math
.
floor
(
args
.
value
||
1
);
const
revealCursor
=
!!
args
.
revealCursor
;
return
{
direction
:
direction
,
unit
:
unit
,
value
:
value
,
revealCursor
:
revealCursor
};
}
export
interface
ParsedArguments
{
direction
:
Direction
;
unit
:
Unit
;
value
:
number
;
revealCursor
:
boolean
;
}
export
const
enum
Direction
{
Up
=
1
,
Down
=
2
}
export
const
enum
Unit
{
Line
=
1
,
WrappedLine
=
2
,
Page
=
3
,
HalfPage
=
4
}
}
export
namespace
RevealLine
{
const
isRevealLineArgs
=
function
(
arg
):
boolean
{
if
(
!
types
.
isObject
(
arg
))
{
return
false
;
}
let
reveaLineArg
:
RawArguments
=
arg
;
if
(
!
types
.
isNumber
(
reveaLineArg
.
lineNumber
))
{
return
false
;
}
if
(
!
types
.
isUndefined
(
reveaLineArg
.
at
)
&&
!
types
.
isString
(
reveaLineArg
.
at
))
{
return
false
;
}
return
true
;
};
export
const
description
=
<
ICommandHandlerDescription
>
{
description
:
'
Reveal the given line at the given logical position
'
,
args
:
[
{
name
:
'
Reveal line argument object
'
,
description
:
`Property-value pairs that can be passed through this argument:
* 'lineNumber': A mandatory line number value.
* 'at': Logical position at which line has to be revealed .
\`\`\`
'top', 'center', 'bottom'
\`\`\`
`
,
constraint
:
isRevealLineArgs
}
]
};
/**
* Arguments for reveal line command
*/
export
interface
RawArguments
{
lineNumber
?:
number
;
at
?:
string
;
};
/**
* Values for reveal line 'at' argument
*/
export
const
RawAtArgument
=
{
Top
:
'
top
'
,
Center
:
'
center
'
,
Bottom
:
'
bottom
'
};
}
export
interface
ICommandKeybindingsOptions
extends
IKeybindings
{
kbExpr
?:
ContextKeyExpr
;
weight
?:
number
;
...
...
src/vs/editor/common/controller/coreCommands.ts
0 → 100644
浏览文件 @
0840d28d
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
SingleCursorState
,
CursorState
}
from
'
vs/editor/common/controller/cursorCommon
'
;
import
{
CursorChangeReason
}
from
"
vs/editor/common/controller/cursorEvents
"
;
import
{
CursorMoveCommands
}
from
"
vs/editor/common/controller/cursorMoveCommands
"
;
import
{
EditorCommand
,
ICommandOptions
}
from
"
vs/editor/common/config/config
"
;
import
{
ServicesAccessor
}
from
"
vs/platform/instantiation/common/instantiation
"
;
import
{
registerEditorCommand
}
from
"
vs/editor/common/editorCommonExtensions
"
;
import
{
ICursors
,
RevealTarget
}
from
"
vs/editor/common/controller/cursor
"
;
export
abstract
class
CoreCommand
extends
EditorCommand
{
public
runEditorCommand
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
,
args
:
any
):
void
{
this
.
runCoreCommand
(
editor
.
getCursors
(),
args
);
}
public
abstract
runCoreCommand
(
cursors
:
ICursors
,
args
:
any
):
void
;
protected
ensureInEditableRange
(
cursors
:
ICursors
,
states
:
CursorState
[]):
CursorState
[]
{
const
model
=
cursors
.
context
.
model
;
if
(
!
model
.
hasEditableRange
())
{
return
states
;
}
const
modelEditableRange
=
model
.
getEditableRange
();
const
viewEditableRange
=
cursors
.
context
.
convertModelRangeToViewRange
(
modelEditableRange
);
let
result
:
CursorState
[]
=
[];
for
(
let
i
=
0
,
len
=
states
.
length
;
i
<
len
;
i
++
)
{
const
state
=
states
[
i
];
if
(
state
.
modelState
)
{
const
newModelState
=
CoreCommand
.
_ensureInEditableRange
(
state
.
modelState
,
modelEditableRange
);
result
[
i
]
=
newModelState
?
CursorState
.
fromModelState
(
newModelState
)
:
state
;
}
else
{
const
newViewState
=
CoreCommand
.
_ensureInEditableRange
(
state
.
viewState
,
viewEditableRange
);
result
[
i
]
=
newViewState
?
CursorState
.
fromViewState
(
newViewState
)
:
state
;
}
}
return
result
;
}
private
static
_ensureInEditableRange
(
state
:
SingleCursorState
,
editableRange
:
Range
):
SingleCursorState
{
const
position
=
state
.
position
;
if
(
position
.
lineNumber
<
editableRange
.
startLineNumber
||
(
position
.
lineNumber
===
editableRange
.
startLineNumber
&&
position
.
column
<
editableRange
.
startColumn
))
{
return
new
SingleCursorState
(
state
.
selectionStart
,
state
.
selectionStartLeftoverVisibleColumns
,
new
Position
(
editableRange
.
startLineNumber
,
editableRange
.
startColumn
),
0
);
}
if
(
position
.
lineNumber
>
editableRange
.
endLineNumber
||
(
position
.
lineNumber
===
editableRange
.
endLineNumber
&&
position
.
column
>
editableRange
.
endColumn
))
{
return
new
SingleCursorState
(
state
.
selectionStart
,
state
.
selectionStartLeftoverVisibleColumns
,
new
Position
(
editableRange
.
endLineNumber
,
editableRange
.
endColumn
),
0
);
}
return
null
;
}
}
export
class
BaseMoveToCommand
extends
CoreCommand
{
private
readonly
_inSelectionMode
:
boolean
;
constructor
(
opts
:
ICommandOptions
&
{
inSelectionMode
:
boolean
;
})
{
super
(
opts
);
this
.
_inSelectionMode
=
opts
.
inSelectionMode
;
}
public
runCoreCommand
(
cursors
:
ICursors
,
args
:
any
):
void
{
cursors
.
context
.
model
.
pushStackElement
();
cursors
.
setStates
(
args
.
source
,
CursorChangeReason
.
Explicit
,
[
CursorMoveCommands
.
moveTo
(
cursors
.
context
,
cursors
.
getPrimaryCursor
(),
this
.
_inSelectionMode
,
args
.
position
,
args
.
viewPosition
)
]
);
cursors
.
reveal
(
true
,
RevealTarget
.
Primary
);
}
}
export
const
CoreCommands
=
{
MoveTo
:
registerEditorCommand
(
new
BaseMoveToCommand
({
id
:
'
moveTo
'
,
inSelectionMode
:
false
,
precondition
:
null
})),
MoveToSelect
:
registerEditorCommand
(
new
BaseMoveToCommand
({
id
:
'
moveToSelect
'
,
inSelectionMode
:
true
,
precondition
:
null
})),
};
src/vs/editor/common/controller/cursor.ts
浏览文件 @
0840d28d
...
...
@@ -21,11 +21,13 @@ import { DeleteOperations } from 'vs/editor/common/controller/cursorDeleteOperat
import
{
TypeOperations
}
from
'
vs/editor/common/controller/cursorTypeOperations
'
;
import
{
TextModelEventType
,
ModelRawContentChangedEvent
,
RawContentChangedType
}
from
'
vs/editor/common/model/textModelEvents
'
;
import
{
CursorEventType
,
CursorChangeReason
,
ICursorPositionChangedEvent
,
VerticalRevealType
,
ICursorSelectionChangedEvent
,
ICursorRevealRangeEvent
,
CursorScrollRequest
}
from
"
vs/editor/common/controller/cursorEvents
"
;
import
{
ICommandHandlerDescription
}
from
"
vs/platform/commands/common/commands
"
;
import
*
as
types
from
'
vs/base/common/types
'
;
import
{
CursorMoveCommands
,
CursorMove
}
from
"
vs/editor/common/controller/cursorMoveCommands
"
;
import
{
RevealLine
,
EditorScroll
}
from
"
vs/editor/common/config/config
"
;
import
{
CommonEditorRegistry
}
from
"
vs/editor/common/editorCommonExtensions
"
;
import
{
ICursor
}
from
"
vs/editor/common/controller/oneCursor
"
;
import
{
CoreCommand
}
from
'
vs/editor/common/controller/coreCommands
'
;
const
enum
RevealTarget
{
export
const
enum
RevealTarget
{
Primary
=
0
,
TopMost
=
1
,
BottomMost
=
2
...
...
@@ -66,7 +68,15 @@ interface ICommandsData {
anyoneHadTrackedRange
:
boolean
;
}
export
class
Cursor
extends
Disposable
{
export
interface
ICursors
{
readonly
context
:
CursorContext
;
getPrimaryCursor
():
ICursor
;
setStates
(
source
:
string
,
reason
:
CursorChangeReason
,
states
:
CursorState
[]):
void
;
reveal
(
horizontal
:
boolean
,
target
:
RevealTarget
):
void
;
}
export
class
Cursor
extends
Disposable
implements
ICursors
{
public
onDidChangePosition
(
listener
:
(
e
:
ICursorPositionChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
_eventEmitter
.
addListener
(
CursorEventType
.
CursorPositionChanged
,
listener
);
...
...
@@ -76,7 +86,7 @@ export class Cursor extends Disposable {
}
private
configuration
:
editorCommon
.
IConfiguration
;
p
rivate
context
:
CursorContext
;
p
ublic
context
:
CursorContext
;
private
model
:
editorCommon
.
IModel
;
private
_eventEmitter
:
EventEmitter
;
...
...
@@ -189,6 +199,53 @@ export class Cursor extends Disposable {
super
.
dispose
();
}
public
getPrimaryCursor
():
ICursor
{
return
this
.
cursors
.
getPrimaryCursor
();
}
public
setStates
(
source
:
string
,
reason
:
CursorChangeReason
,
states
:
CursorState
[]):
void
{
const
oldSelections
=
this
.
cursors
.
getSelections
();
const
oldViewSelections
=
this
.
cursors
.
getViewSelections
();
// TODO@Alex
// ensure valid state on all cursors
// this.cursors.ensureValidState();
this
.
cursors
.
setStates
(
states
,
false
);
this
.
cursors
.
normalize
();
// TODO@Alex
this
.
_columnSelectData
=
null
;
const
newSelections
=
this
.
cursors
.
getSelections
();
const
newViewSelections
=
this
.
cursors
.
getViewSelections
();
let
somethingChanged
=
false
;
if
(
oldSelections
.
length
!==
newSelections
.
length
)
{
somethingChanged
=
true
;
}
else
{
for
(
let
i
=
0
,
len
=
oldSelections
.
length
;
!
somethingChanged
&&
i
<
len
;
i
++
)
{
if
(
!
oldSelections
[
i
].
equalsSelection
(
newSelections
[
i
]))
{
somethingChanged
=
true
;
}
}
for
(
let
i
=
0
,
len
=
oldViewSelections
.
length
;
!
somethingChanged
&&
i
<
len
;
i
++
)
{
if
(
!
oldViewSelections
[
i
].
equalsSelection
(
newViewSelections
[
i
]))
{
somethingChanged
=
true
;
}
}
}
if
(
somethingChanged
)
{
this
.
emitCursorPositionChanged
(
source
,
reason
);
this
.
emitCursorSelectionChanged
(
source
,
reason
);
}
}
public
reveal
(
horizontal
:
boolean
,
target
:
RevealTarget
):
void
{
this
.
revealRange
(
target
,
VerticalRevealType
.
Simple
,
horizontal
);
}
public
saveState
():
editorCommon
.
ICursorState
[]
{
var
selections
=
this
.
cursors
.
getSelections
(),
...
...
@@ -805,6 +862,14 @@ export class Cursor extends Disposable {
public
trigger
(
source
:
string
,
handlerId
:
string
,
payload
:
any
):
void
{
if
(
!
this
.
_handlers
.
hasOwnProperty
(
handlerId
))
{
const
command
=
CommonEditorRegistry
.
getEditorCommand
(
handlerId
);
if
(
!
command
||
!
(
command
instanceof
CoreCommand
))
{
return
;
}
payload
=
payload
||
{};
payload
.
source
=
source
;
command
.
runCoreCommand
(
this
,
payload
);
return
;
}
let
handler
=
this
.
_handlers
[
handlerId
];
...
...
@@ -815,8 +880,6 @@ export class Cursor extends Disposable {
let
H
=
editorCommon
.
Handler
;
this
.
_handlers
[
H
.
CursorMove
]
=
(
ctx
)
=>
this
.
_cursorMove
(
ctx
);
this
.
_handlers
[
H
.
MoveTo
]
=
(
ctx
)
=>
this
.
_moveTo
(
false
,
ctx
);
this
.
_handlers
[
H
.
MoveToSelect
]
=
(
ctx
)
=>
this
.
_moveTo
(
true
,
ctx
);
this
.
_handlers
[
H
.
ColumnSelect
]
=
(
ctx
)
=>
this
.
_columnSelectMouse
(
ctx
);
this
.
_handlers
[
H
.
AddCursorUp
]
=
(
ctx
)
=>
this
.
_addCursorUp
(
ctx
);
this
.
_handlers
[
H
.
AddCursorDown
]
=
(
ctx
)
=>
this
.
_addCursorDown
(
ctx
);
...
...
@@ -907,16 +970,6 @@ export class Cursor extends Disposable {
this
.
_handlers
[
H
.
RevealLine
]
=
(
ctx
)
=>
this
.
_revealLine
(
ctx
);
}
private
_moveTo
(
inSelectionMode
:
boolean
,
ctx
:
IMultipleCursorOperationContext
):
void
{
ctx
.
shouldPushStackElementBefore
=
true
;
ctx
.
shouldPushStackElementAfter
=
true
;
if
(
ctx
.
eventSource
===
'
mouse
'
)
{
ctx
.
cursorPositionChangeReason
=
CursorChangeReason
.
Explicit
;
}
const
result
=
CursorMoveCommands
.
moveTo
(
this
.
context
,
this
.
cursors
.
getPrimaryCursor
(),
inSelectionMode
,
ctx
.
eventData
.
position
,
ctx
.
eventData
.
viewPosition
);
this
.
cursors
.
setStates
([
result
],
false
);
}
private
_cursorMove
(
ctx
:
IMultipleCursorOperationContext
):
void
{
const
args
=
CursorMove
.
parse
(
ctx
.
eventData
);
if
(
!
args
)
{
...
...
@@ -1520,199 +1573,3 @@ export class Cursor extends Disposable {
}
}
}
export
namespace
EditorScroll
{
const
isEditorScrollArgs
=
function
(
arg
):
boolean
{
if
(
!
types
.
isObject
(
arg
))
{
return
false
;
}
let
scrollArg
:
RawArguments
=
arg
;
if
(
!
types
.
isString
(
scrollArg
.
to
))
{
return
false
;
}
if
(
!
types
.
isUndefined
(
scrollArg
.
by
)
&&
!
types
.
isString
(
scrollArg
.
by
))
{
return
false
;
}
if
(
!
types
.
isUndefined
(
scrollArg
.
value
)
&&
!
types
.
isNumber
(
scrollArg
.
value
))
{
return
false
;
}
if
(
!
types
.
isUndefined
(
scrollArg
.
revealCursor
)
&&
!
types
.
isBoolean
(
scrollArg
.
revealCursor
))
{
return
false
;
}
return
true
;
};
export
const
description
=
<
ICommandHandlerDescription
>
{
description
:
'
Scroll editor in the given direction
'
,
args
:
[
{
name
:
'
Editor scroll argument object
'
,
description
:
`Property-value pairs that can be passed through this argument:
* 'to': A mandatory direction value.
\`\`\`
'up', 'down'
\`\`\`
* 'by': Unit to move. Default is computed based on 'to' value.
\`\`\`
'line', 'wrappedLine', 'page', 'halfPage'
\`\`\`
* 'value': Number of units to move. Default is '1'.
* 'revealCursor': If 'true' reveals the cursor if it is outside view port.
`
,
constraint
:
isEditorScrollArgs
}
]
};
/**
* Directions in the view for editor scroll command.
*/
export
const
RawDirection
=
{
Up
:
'
up
'
,
Down
:
'
down
'
,
};
/**
* Units for editor scroll 'by' argument
*/
export
const
RawUnit
=
{
Line
:
'
line
'
,
WrappedLine
:
'
wrappedLine
'
,
Page
:
'
page
'
,
HalfPage
:
'
halfPage
'
};
/**
* Arguments for editor scroll command
*/
export
interface
RawArguments
{
to
:
string
;
by
?:
string
;
value
?:
number
;
revealCursor
?:
boolean
;
};
export
function
parse
(
args
:
RawArguments
):
ParsedArguments
{
let
direction
:
Direction
;
switch
(
args
.
to
)
{
case
RawDirection
.
Up
:
direction
=
Direction
.
Up
;
break
;
case
RawDirection
.
Down
:
direction
=
Direction
.
Down
;
break
;
default
:
// Illegal arguments
return
null
;
}
let
unit
:
Unit
;
switch
(
args
.
by
)
{
case
RawUnit
.
Line
:
unit
=
Unit
.
Line
;
break
;
case
RawUnit
.
WrappedLine
:
unit
=
Unit
.
WrappedLine
;
break
;
case
RawUnit
.
Page
:
unit
=
Unit
.
Page
;
break
;
case
RawUnit
.
HalfPage
:
unit
=
Unit
.
HalfPage
;
break
;
default
:
unit
=
Unit
.
WrappedLine
;
}
const
value
=
Math
.
floor
(
args
.
value
||
1
);
const
revealCursor
=
!!
args
.
revealCursor
;
return
{
direction
:
direction
,
unit
:
unit
,
value
:
value
,
revealCursor
:
revealCursor
};
}
export
interface
ParsedArguments
{
direction
:
Direction
;
unit
:
Unit
;
value
:
number
;
revealCursor
:
boolean
;
}
export
const
enum
Direction
{
Up
=
1
,
Down
=
2
}
export
const
enum
Unit
{
Line
=
1
,
WrappedLine
=
2
,
Page
=
3
,
HalfPage
=
4
}
}
export
namespace
RevealLine
{
const
isRevealLineArgs
=
function
(
arg
):
boolean
{
if
(
!
types
.
isObject
(
arg
))
{
return
false
;
}
let
reveaLineArg
:
RawArguments
=
arg
;
if
(
!
types
.
isNumber
(
reveaLineArg
.
lineNumber
))
{
return
false
;
}
if
(
!
types
.
isUndefined
(
reveaLineArg
.
at
)
&&
!
types
.
isString
(
reveaLineArg
.
at
))
{
return
false
;
}
return
true
;
};
export
const
description
=
<
ICommandHandlerDescription
>
{
description
:
'
Reveal the given line at the given logical position
'
,
args
:
[
{
name
:
'
Reveal line argument object
'
,
description
:
`Property-value pairs that can be passed through this argument:
* 'lineNumber': A mandatory line number value.
* 'at': Logical position at which line has to be revealed .
\`\`\`
'top', 'center', 'bottom'
\`\`\`
`
,
constraint
:
isRevealLineArgs
}
]
};
/**
* Arguments for reveal line command
*/
export
interface
RawArguments
{
lineNumber
?:
number
;
at
?:
string
;
};
/**
* Values for reveal line 'at' argument
*/
export
const
RawAtArgument
=
{
Top
:
'
top
'
,
Center
:
'
center
'
,
Bottom
:
'
bottom
'
};
}
src/vs/editor/common/editorCommon.ts
浏览文件 @
0840d28d
...
...
@@ -23,6 +23,7 @@ import {
}
from
'
vs/editor/common/model/textModelEvents
'
;
import
*
as
editorOptions
from
"
vs/editor/common/config/editorOptions
"
;
import
{
ICursorPositionChangedEvent
,
ICursorSelectionChangedEvent
}
from
"
vs/editor/common/controller/cursorEvents
"
;
import
{
ICursors
}
from
"
vs/editor/common/controller/cursor
"
;
/**
* Vertical Lane in the overview ruler of the editor.
...
...
@@ -1884,6 +1885,11 @@ export interface ICommonCodeEditor extends IEditor {
*/
executeCommands
(
source
:
string
,
commands
:
ICommand
[]):
void
;
/**
* @internal
*/
getCursors
():
ICursors
;
/**
* Get all the decorations on a line (filtering out decorations from other editors).
*/
...
...
@@ -2020,6 +2026,7 @@ export function isCommonDiffEditor(thing: any): thing is ICommonDiffEditor {
/**
* Built-in commands.
* @internal
*/
export
var
Handler
=
{
ExecuteCommand
:
'
executeCommand
'
,
...
...
@@ -2065,8 +2072,6 @@ export var Handler = {
AddCursorDown
:
'
addCursorDown
'
,
AddCursorUp
:
'
addCursorUp
'
,
MoveTo
:
'
moveTo
'
,
MoveToSelect
:
'
moveToSelect
'
,
ColumnSelect
:
'
columnSelect
'
,
CreateCursor
:
'
createCursor
'
,
LastCursorMoveToSelect
:
'
lastCursorMoveToSelect
'
,
...
...
src/vs/editor/common/editorCommonExtensions.ts
浏览文件 @
0840d28d
...
...
@@ -97,7 +97,12 @@ export function editorAction(ctor: { new (): EditorAction; }): void {
}
export
function
editorCommand
(
ctor
:
{
new
():
ConfigEditorCommand
}):
void
{
CommonEditorRegistry
.
registerEditorCommand
(
new
ctor
());
registerEditorCommand
(
new
ctor
());
}
export
function
registerEditorCommand
<
T
extends
ConfigEditorCommand
>
(
editorCommand
:
T
):
T
{
CommonEditorRegistry
.
registerEditorCommand
(
editorCommand
);
return
editorCommand
;
}
export
function
commonEditorContribution
(
ctor
:
ICommonEditorContributionCtor
):
void
{
...
...
@@ -108,12 +113,15 @@ export module CommonEditorRegistry {
// --- Editor Actions
export
function
registerEditorAction
(
desc
:
EditorAction
)
{
EditorContributionRegistry
.
INSTANCE
.
registerEditorAction
(
desc
);
export
function
registerEditorAction
(
editorAction
:
EditorAction
)
{
EditorContributionRegistry
.
INSTANCE
.
registerEditorAction
(
editorAction
);
}
export
function
getEditorActions
():
EditorAction
[]
{
return
EditorContributionRegistry
.
INSTANCE
.
getEditorActions
();
}
export
function
getEditorCommand
(
commandId
:
string
):
ConfigEditorCommand
{
return
EditorContributionRegistry
.
INSTANCE
.
getEditorCommand
(
commandId
);
}
// --- Editor Contributions
...
...
@@ -127,8 +135,8 @@ export module CommonEditorRegistry {
return
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(
importance
);
}
export
function
registerEditorCommand
(
desc
:
ConfigBasic
Command
):
void
{
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
desc
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
())
);
export
function
registerEditorCommand
(
editorCommand
:
ConfigEditor
Command
):
void
{
EditorContributionRegistry
.
INSTANCE
.
registerEditorCommand
(
editorCommand
);
}
export
function
registerLanguageCommand
(
id
:
string
,
handler
:
(
accessor
:
ServicesAccessor
,
args
:
{
[
n
:
string
]:
any
})
=>
any
)
{
...
...
@@ -169,10 +177,12 @@ class EditorContributionRegistry {
private
editorContributions
:
ICommonEditorContributionCtor
[];
private
editorActions
:
EditorAction
[];
private
editorCommands
:
{
[
commandId
:
string
]:
ConfigEditorCommand
;
};
constructor
()
{
this
.
editorContributions
=
[];
this
.
editorActions
=
[];
this
.
editorCommands
=
Object
.
create
(
null
);
}
public
registerEditorContribution
(
ctor
:
ICommonEditorContributionCtor
):
void
{
...
...
@@ -198,5 +208,15 @@ class EditorContributionRegistry {
public
getEditorActions
():
EditorAction
[]
{
return
this
.
editorActions
.
slice
(
0
);
}
public
registerEditorCommand
(
editorCommand
:
ConfigEditorCommand
)
{
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
editorCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
this
.
editorCommands
[
editorCommand
.
id
]
=
editorCommand
;
}
public
getEditorCommand
(
commandId
:
string
):
ConfigEditorCommand
{
return
(
this
.
editorCommands
[
commandId
]
||
null
);
}
}
Registry
.
add
(
Extensions
.
EditorCommonContributions
,
EditorContributionRegistry
.
INSTANCE
);
src/vs/editor/contrib/accessibility/browser/accessibility.ts
浏览文件 @
0840d28d
...
...
@@ -252,8 +252,8 @@ class ToggleExperimentalScreenReaderSupportCommand extends Command {
GlobalScreenReaderNVDA
.
setValue
(
!
currentValue
);
}
}
CommonEditorRegistry
.
registerEditorCommand
(
new
ToggleExperimentalScreenReaderSupportCommand
(
));
const
command
=
new
ToggleExperimentalScreenReaderSupportCommand
();
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
command
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()
));
registerThemingParticipant
((
theme
,
collector
)
=>
{
let
widgetBackground
=
theme
.
getColor
(
editorWidgetBackground
);
...
...
src/vs/editor/contrib/find/test/common/findModel.test.ts
浏览文件 @
0840d28d
...
...
@@ -9,10 +9,11 @@ import { Cursor } from 'vs/editor/common/controller/cursor';
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Handler
,
ICommonCodeEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommonCodeEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
FindModelBoundToEditorModel
}
from
'
vs/editor/contrib/find/common/findModel
'
;
import
{
FindReplaceState
}
from
'
vs/editor/contrib/find/common/findState
'
;
import
{
withMockCodeEditor
}
from
'
vs/editor/test/common/mocks/mockCodeEditor
'
;
import
{
CoreCommands
}
from
"
vs/editor/common/controller/coreCommands
"
;
suite
(
'
FindModel
'
,
()
=>
{
...
...
@@ -302,7 +303,7 @@ suite('FindModel', () => {
]
);
cursor
.
trigger
(
'
mouse
'
,
Handler
.
MoveTo
,
{
cursor
.
trigger
(
'
mouse
'
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
6
,
20
)
});
...
...
@@ -662,7 +663,7 @@ suite('FindModel', () => {
]
);
cursor
.
trigger
(
'
mouse
'
,
Handler
.
MoveTo
,
{
cursor
.
trigger
(
'
mouse
'
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
6
,
20
)
});
assertFindState
(
...
...
@@ -1149,7 +1150,7 @@ suite('FindModel', () => {
]
);
cursor
.
trigger
(
'
mouse
'
,
Handler
.
MoveTo
,
{
cursor
.
trigger
(
'
mouse
'
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
6
,
20
)
});
assertFindState
(
...
...
@@ -1310,7 +1311,7 @@ suite('FindModel', () => {
]
);
cursor
.
trigger
(
'
mouse
'
,
Handler
.
MoveTo
,
{
cursor
.
trigger
(
'
mouse
'
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
6
,
20
)
});
assertFindState
(
...
...
@@ -1740,7 +1741,7 @@ suite('FindModel', () => {
findState
.
change
({
searchString
:
'
hello(?=
\\
sworld)
'
,
replaceString
:
'
hi
'
,
isRegex
:
true
},
false
);
let
findModel
=
new
FindModelBoundToEditorModel
(
editor
,
findState
);
cursor
.
trigger
(
'
mouse
'
,
Handler
.
MoveTo
,
{
cursor
.
trigger
(
'
mouse
'
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
8
,
14
)
});
...
...
src/vs/editor/test/common/controller/cursor.test.ts
浏览文件 @
0840d28d
...
...
@@ -24,6 +24,7 @@ import { LanguageIdentifier } from 'vs/editor/common/modes';
import
{
viewModelHelper
}
from
'
vs/editor/test/common/editorTestUtils
'
;
import
{
IEditorOptions
}
from
"
vs/editor/common/config/editorOptions
"
;
import
{
ICursorPositionChangedEvent
,
ICursorSelectionChangedEvent
}
from
"
vs/editor/common/controller/cursorEvents
"
;
import
{
CoreCommands
}
from
"
vs/editor/common/controller/coreCommands
"
;
let
H
=
Handler
;
...
...
@@ -34,7 +35,15 @@ function cursorCommand(cursor: Cursor, command: string, extraData?: any, overwri
}
function
moveTo
(
cursor
:
Cursor
,
lineNumber
:
number
,
column
:
number
,
inSelectionMode
:
boolean
=
false
)
{
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
MoveToSelect
:
H
.
MoveTo
,
{
position
:
new
Position
(
lineNumber
,
column
)
});
if
(
inSelectionMode
)
{
CoreCommands
.
MoveToSelect
.
runCoreCommand
(
cursor
,
{
position
:
new
Position
(
lineNumber
,
column
)
});
}
else
{
CoreCommands
.
MoveTo
.
runCoreCommand
(
cursor
,
{
position
:
new
Position
(
lineNumber
,
column
)
});
}
}
function
moveLeft
(
cursor
:
Cursor
,
inSelectionMode
:
boolean
=
false
)
{
...
...
@@ -1720,7 +1729,7 @@ suite('Editor Controller - Cursor Configuration', () => {
],
modelOpts
:
{
insertSpaces
:
true
,
tabSize
:
4
,
detectIndentation
:
false
,
defaultEOL
:
DefaultEndOfLine
.
LF
,
trimAutoWhitespace
:
true
}
},
(
model
,
cursor
)
=>
{
cursorCommand
(
cursor
,
H
.
MoveTo
,
{
position
:
new
Position
(
1
,
21
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
1
,
21
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
H
.
Type
,
{
text
:
'
\n
'
},
'
keyboard
'
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
\t
My First Line
\t
'
);
assert
.
equal
(
model
.
getLineContent
(
2
),
'
'
);
...
...
@@ -1739,56 +1748,56 @@ suite('Editor Controller - Cursor Configuration', () => {
modelOpts
:
{
insertSpaces
:
true
,
tabSize
:
13
,
detectIndentation
:
false
,
defaultEOL
:
DefaultEndOfLine
.
LF
,
trimAutoWhitespace
:
true
}
},
(
model
,
cursor
)
=>
{
// Tab on column 1
cursorCommand
(
cursor
,
H
.
MoveTo
,
{
position
:
new
Position
(
2
,
1
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
2
,
1
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
H
.
Tab
,
null
,
'
keyboard
'
);
assert
.
equal
(
model
.
getLineContent
(
2
),
'
My Second Line123
'
);
cursorCommand
(
cursor
,
H
.
Undo
,
null
,
'
keyboard
'
);
// Tab on column 2
assert
.
equal
(
model
.
getLineContent
(
2
),
'
My Second Line123
'
);
cursorCommand
(
cursor
,
H
.
MoveTo
,
{
position
:
new
Position
(
2
,
2
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
2
,
2
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
H
.
Tab
,
null
,
'
keyboard
'
);
assert
.
equal
(
model
.
getLineContent
(
2
),
'
M y Second Line123
'
);
cursorCommand
(
cursor
,
H
.
Undo
,
null
,
'
keyboard
'
);
// Tab on column 3
assert
.
equal
(
model
.
getLineContent
(
2
),
'
My Second Line123
'
);
cursorCommand
(
cursor
,
H
.
MoveTo
,
{
position
:
new
Position
(
2
,
3
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
2
,
3
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
H
.
Tab
,
null
,
'
keyboard
'
);
assert
.
equal
(
model
.
getLineContent
(
2
),
'
My Second Line123
'
);
cursorCommand
(
cursor
,
H
.
Undo
,
null
,
'
keyboard
'
);
// Tab on column 4
assert
.
equal
(
model
.
getLineContent
(
2
),
'
My Second Line123
'
);
cursorCommand
(
cursor
,
H
.
MoveTo
,
{
position
:
new
Position
(
2
,
4
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
2
,
4
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
H
.
Tab
,
null
,
'
keyboard
'
);
assert
.
equal
(
model
.
getLineContent
(
2
),
'
My Second Line123
'
);
cursorCommand
(
cursor
,
H
.
Undo
,
null
,
'
keyboard
'
);
// Tab on column 5
assert
.
equal
(
model
.
getLineContent
(
2
),
'
My Second Line123
'
);
cursorCommand
(
cursor
,
H
.
MoveTo
,
{
position
:
new
Position
(
2
,
5
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
2
,
5
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
H
.
Tab
,
null
,
'
keyboard
'
);
assert
.
equal
(
model
.
getLineContent
(
2
),
'
My S econd Line123
'
);
cursorCommand
(
cursor
,
H
.
Undo
,
null
,
'
keyboard
'
);
// Tab on column 5
assert
.
equal
(
model
.
getLineContent
(
2
),
'
My Second Line123
'
);
cursorCommand
(
cursor
,
H
.
MoveTo
,
{
position
:
new
Position
(
2
,
5
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
2
,
5
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
H
.
Tab
,
null
,
'
keyboard
'
);
assert
.
equal
(
model
.
getLineContent
(
2
),
'
My S econd Line123
'
);
cursorCommand
(
cursor
,
H
.
Undo
,
null
,
'
keyboard
'
);
// Tab on column 13
assert
.
equal
(
model
.
getLineContent
(
2
),
'
My Second Line123
'
);
cursorCommand
(
cursor
,
H
.
MoveTo
,
{
position
:
new
Position
(
2
,
13
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
2
,
13
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
H
.
Tab
,
null
,
'
keyboard
'
);
assert
.
equal
(
model
.
getLineContent
(
2
),
'
My Second Li ne123
'
);
cursorCommand
(
cursor
,
H
.
Undo
,
null
,
'
keyboard
'
);
// Tab on column 14
assert
.
equal
(
model
.
getLineContent
(
2
),
'
My Second Line123
'
);
cursorCommand
(
cursor
,
H
.
MoveTo
,
{
position
:
new
Position
(
2
,
14
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
2
,
14
)
},
'
keyboard
'
);
cursorCommand
(
cursor
,
H
.
Tab
,
null
,
'
keyboard
'
);
assert
.
equal
(
model
.
getLineContent
(
2
),
'
My Second Lin e123
'
);
});
...
...
src/vs/editor/test/common/controller/cursorMoveCommand.test.ts
浏览文件 @
0840d28d
...
...
@@ -17,6 +17,7 @@ import { Range } from 'vs/editor/common/core/range';
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
IEditorOptions
}
from
"
vs/editor/common/config/editorOptions
"
;
import
{
IViewModelHelper
}
from
"
vs/editor/common/controller/cursorCommon
"
;
import
{
CoreCommands
}
from
"
vs/editor/common/controller/coreCommands
"
;
let
H
=
Handler
;
...
...
@@ -561,7 +562,15 @@ function selectionEqual(selection: Selection, posLineNumber: number, posColumn:
}
function
moveTo
(
cursor
:
Cursor
,
lineNumber
:
number
,
column
:
number
,
inSelectionMode
:
boolean
=
false
)
{
cursorCommand
(
cursor
,
inSelectionMode
?
H
.
MoveToSelect
:
H
.
MoveTo
,
{
position
:
new
Position
(
lineNumber
,
column
)
});
if
(
inSelectionMode
)
{
CoreCommands
.
MoveToSelect
.
runCoreCommand
(
cursor
,
{
position
:
new
Position
(
lineNumber
,
column
)
});
}
else
{
CoreCommands
.
MoveTo
.
runCoreCommand
(
cursor
,
{
position
:
new
Position
(
lineNumber
,
column
)
});
}
}
function
moveToEndOfLine
(
cursor
:
Cursor
,
inSelectionMode
:
boolean
=
false
)
{
...
...
src/vs/monaco.d.ts
浏览文件 @
0840d28d
...
...
@@ -2349,81 +2349,6 @@ declare module monaco.editor {
IDiffEditor
:
string
;
};
/**
* Built-in commands.
*/
export
var
Handler
:
{
ExecuteCommand
:
string
;
ExecuteCommands
:
string
;
CursorLeft
:
string
;
CursorLeftSelect
:
string
;
CursorRight
:
string
;
CursorRightSelect
:
string
;
CursorUp
:
string
;
CursorUpSelect
:
string
;
CursorDown
:
string
;
CursorDownSelect
:
string
;
CursorPageUp
:
string
;
CursorPageUpSelect
:
string
;
CursorPageDown
:
string
;
CursorPageDownSelect
:
string
;
CursorHome
:
string
;
CursorHomeSelect
:
string
;
CursorEnd
:
string
;
CursorEndSelect
:
string
;
ExpandLineSelection
:
string
;
CursorTop
:
string
;
CursorTopSelect
:
string
;
CursorBottom
:
string
;
CursorBottomSelect
:
string
;
CursorColumnSelectLeft
:
string
;
CursorColumnSelectRight
:
string
;
CursorColumnSelectUp
:
string
;
CursorColumnSelectPageUp
:
string
;
CursorColumnSelectDown
:
string
;
CursorColumnSelectPageDown
:
string
;
CursorMove
:
string
;
AddCursorDown
:
string
;
AddCursorUp
:
string
;
MoveTo
:
string
;
MoveToSelect
:
string
;
ColumnSelect
:
string
;
CreateCursor
:
string
;
LastCursorMoveToSelect
:
string
;
Type
:
string
;
ReplacePreviousChar
:
string
;
CompositionStart
:
string
;
CompositionEnd
:
string
;
Paste
:
string
;
Tab
:
string
;
Indent
:
string
;
Outdent
:
string
;
DeleteLeft
:
string
;
DeleteRight
:
string
;
RemoveSecondaryCursors
:
string
;
CancelSelection
:
string
;
Cut
:
string
;
Undo
:
string
;
Redo
:
string
;
WordSelect
:
string
;
WordSelectDrag
:
string
;
LastCursorWordSelect
:
string
;
LineSelect
:
string
;
LineSelectDrag
:
string
;
LastCursorLineSelect
:
string
;
LastCursorLineSelectDrag
:
string
;
LineInsertBefore
:
string
;
LineInsertAfter
:
string
;
LineBreakInsert
:
string
;
SelectAll
:
string
;
EditorScroll
:
string
;
ScrollLineUp
:
string
;
ScrollLineDown
:
string
;
ScrollPageUp
:
string
;
ScrollPageDown
:
string
;
RevealLine
:
string
;
};
/**
* An event describing that the current mode associated with a model has changed.
*/
...
...
src/vs/workbench/parts/preferences/browser/preferencesEditor.ts
浏览文件 @
0840d28d
...
...
@@ -30,7 +30,7 @@ import { editorContribution } from 'vs/editor/browser/editorBrowserExtensions';
import
{
ICodeEditor
,
IEditorContributionCtor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
SearchWidget
,
SettingsTabsWidget
}
from
'
vs/workbench/parts/preferences/browser/preferencesWidgets
'
;
import
{
ContextKeyExpr
,
IContextKeyService
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
Comm
onEditorRegistry
,
Comm
and
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
Command
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IWorkbenchThemeService
}
from
'
vs/workbench/services/themes/common/workbenchThemeService
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
...
...
@@ -52,6 +52,7 @@ import { FoldingController } from 'vs/editor/contrib/folding/browser/folding';
import
{
FindController
}
from
'
vs/editor/contrib/find/browser/find
'
;
import
{
SelectionHighlighter
}
from
'
vs/editor/contrib/find/common/findController
'
;
import
{
IEditorOptions
}
from
"
vs/editor/common/config/editorOptions
"
;
import
{
KeybindingsRegistry
}
from
"
vs/platform/keybinding/common/keybindingsRegistry
"
;
export
class
PreferencesEditorInput
extends
SideBySideEditorInput
{
public
static
ID
:
string
=
'
workbench.editorinputs.preferencesEditorInput
'
;
...
...
@@ -654,8 +655,9 @@ class StartSearchDefaultSettingsCommand extends Command {
}
}
CommonEditorRegistry
.
registerEditorCommand
(
new
StartSearchDefaultSettingsCommand
({
const
command
=
new
StartSearchDefaultSettingsCommand
({
id
:
SETTINGS_EDITOR_COMMAND_SEARCH
,
precondition
:
ContextKeyExpr
.
and
(
CONTEXT_SETTINGS_EDITOR
),
kbOpts
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_F
}
}));
\ No newline at end of file
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
command
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
src/vs/workbench/test/common/editor/rangeDecorations.test.ts
浏览文件 @
0840d28d
...
...
@@ -24,6 +24,7 @@ import { Cursor } from 'vs/editor/common/controller/cursor';
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
TestConfigurationService
}
from
'
vs/platform/configuration/test/common/testConfigurationService
'
;
import
{
ModelServiceImpl
}
from
'
vs/editor/common/services/modelServiceImpl
'
;
import
{
CoreCommands
}
from
"
vs/editor/common/controller/coreCommands
"
;
suite
(
'
Editor - Range decorations
'
,
()
=>
{
...
...
@@ -110,7 +111,7 @@ suite('Editor - Range decorations', () => {
test
(
'
highlight is removed on cursor position change
'
,
function
()
{
testObject
.
highlightRange
({
resource
:
model
.
uri
,
range
:
{
startLineNumber
:
1
,
startColumn
:
1
,
endLineNumber
:
1
,
endColumn
:
1
}
});
cursor
.
trigger
(
'
mouse
'
,
editorCommon
.
Handler
.
MoveTo
,
{
cursor
.
trigger
(
'
mouse
'
,
CoreCommands
.
MoveTo
.
id
,
{
position
:
new
Position
(
2
,
1
)
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录