Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
05fc8ae1
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,发现更多精彩内容 >>
提交
05fc8ae1
编写于
11月 21, 2016
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move delete all left action to contrib
上级
3e30272d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
76 addition
and
48 deletion
+76
-48
src/vs/editor/common/config/config.ts
src/vs/editor/common/config/config.ts
+0
-10
src/vs/editor/common/controller/cursor.ts
src/vs/editor/common/controller/cursor.ts
+0
-5
src/vs/editor/common/controller/cursorDeleteOperations.ts
src/vs/editor/common/controller/cursorDeleteOperations.ts
+0
-31
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+0
-1
src/vs/editor/contrib/linesOperations/common/linesOperations.ts
.../editor/contrib/linesOperations/common/linesOperations.ts
+38
-0
src/vs/editor/contrib/linesOperations/test/common/linesOperations.test.ts
...ntrib/linesOperations/test/common/linesOperations.test.ts
+38
-0
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+0
-1
未找到文件。
src/vs/editor/common/config/config.ts
浏览文件 @
05fc8ae1
...
...
@@ -603,16 +603,6 @@ registerCommand(new CoreCommand({
mac
:
{
primary
:
KeyCode
.
Delete
,
secondary
:
[
KeyMod
.
WinCtrl
|
KeyCode
.
KEY_D
,
KeyMod
.
WinCtrl
|
KeyCode
.
Delete
]
}
}
}));
registerCommand
(
new
CoreCommand
({
id
:
H
.
DeleteAllLeft
,
precondition
:
EditorContextKeys
.
Writable
,
kbOpts
:
{
weight
:
CORE_WEIGHT
,
kbExpr
:
EditorContextKeys
.
TextFocus
,
primary
:
null
,
mac
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
Backspace
}
}
}));
registerCommand
(
new
CoreCommand
({
id
:
H
.
DeleteAllRight
,
precondition
:
EditorContextKeys
.
Writable
,
...
...
src/vs/editor/common/controller/cursor.ts
浏览文件 @
05fc8ae1
...
...
@@ -1009,7 +1009,6 @@ export class Cursor extends EventEmitter {
this
.
_handlers
[
H
.
DeleteWordStartRight
]
=
(
ctx
)
=>
this
.
_deleteWordRight
(
false
,
WordNavigationType
.
WordStart
,
ctx
);
this
.
_handlers
[
H
.
DeleteWordEndRight
]
=
(
ctx
)
=>
this
.
_deleteWordRight
(
false
,
WordNavigationType
.
WordEnd
,
ctx
);
this
.
_handlers
[
H
.
DeleteAllLeft
]
=
(
ctx
)
=>
this
.
_deleteAllLeft
(
ctx
);
this
.
_handlers
[
H
.
DeleteAllRight
]
=
(
ctx
)
=>
this
.
_deleteAllRight
(
ctx
);
this
.
_handlers
[
H
.
Cut
]
=
(
ctx
)
=>
this
.
_cut
(
ctx
);
...
...
@@ -1518,10 +1517,6 @@ export class Cursor extends EventEmitter {
return
this
.
_applyEditForAll
(
ctx
,
(
cursor
)
=>
WordOperations
.
deleteWordRight
(
cursor
.
config
,
cursor
.
model
,
cursor
.
modelState
,
whitespaceHeuristics
,
wordNavigationType
));
}
private
_deleteAllLeft
(
ctx
:
IMultipleCursorOperationContext
):
boolean
{
return
this
.
_applyEditForAll
(
ctx
,
(
cursor
)
=>
DeleteOperations
.
deleteAllLeft
(
cursor
.
config
,
cursor
.
model
,
cursor
.
modelState
));
}
private
_deleteAllRight
(
ctx
:
IMultipleCursorOperationContext
):
boolean
{
return
this
.
_applyEditForAll
(
ctx
,
(
cursor
)
=>
DeleteOperations
.
deleteAllRight
(
cursor
.
config
,
cursor
.
model
,
cursor
.
modelState
));
}
...
...
src/vs/editor/common/controller/cursorDeleteOperations.ts
浏览文件 @
05fc8ae1
...
...
@@ -164,37 +164,6 @@ export class DeleteOperations {
});
}
public
static
deleteAllLeft
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
):
EditOperationResult
{
let
r
=
this
.
autoClosingPairDelete
(
config
,
model
,
cursor
);
if
(
r
)
{
// This was a case for an auto-closing pair delete
return
r
;
}
let
selection
=
cursor
.
selection
;
if
(
selection
.
isEmpty
())
{
let
position
=
cursor
.
position
;
let
lineNumber
=
position
.
lineNumber
;
let
column
=
position
.
column
;
if
(
column
===
1
)
{
// Ignore deleting at beginning of line
return
null
;
}
let
deleteSelection
=
new
Range
(
lineNumber
,
1
,
lineNumber
,
column
);
if
(
!
deleteSelection
.
isEmpty
())
{
return
new
EditOperationResult
(
new
ReplaceCommand
(
deleteSelection
,
''
),
{
shouldPushStackElementBefore
:
false
,
shouldPushStackElementAfter
:
false
});
}
}
return
this
.
deleteLeft
(
config
,
model
,
cursor
);
}
public
static
cut
(
config
:
CursorConfiguration
,
model
:
ICursorSimpleModel
,
cursor
:
SingleCursorState
,
enableEmptySelectionClipboard
:
boolean
):
EditOperationResult
{
let
selection
=
cursor
.
selection
;
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
05fc8ae1
...
...
@@ -4583,7 +4583,6 @@ export var Handler = {
DeleteWordStartRight
:
'
deleteWordStartRight
'
,
DeleteWordEndRight
:
'
deleteWordEndRight
'
,
DeleteAllLeft
:
'
deleteAllLeft
'
,
DeleteAllRight
:
'
deleteAllRight
'
,
RemoveSecondaryCursors
:
'
removeSecondaryCursors
'
,
...
...
src/vs/editor/contrib/linesOperations/common/linesOperations.ts
浏览文件 @
05fc8ae1
...
...
@@ -9,6 +9,8 @@ import { KeyCode, KeyMod, KeyChord } from 'vs/base/common/keyCodes';
import
{
SortLinesCommand
}
from
'
vs/editor/contrib/linesOperations/common/sortLinesCommand
'
;
import
{
TrimTrailingWhitespaceCommand
}
from
'
vs/editor/common/commands/trimTrailingWhitespaceCommand
'
;
import
{
EditorContextKeys
,
Handler
,
ICommand
,
ICommonCodeEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ReplaceCommand
}
from
'
vs/editor/common/commands/replaceCommand
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
editorAction
,
ServicesAccessor
,
IActionOptions
,
EditorAction
,
HandlerEditorAction
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
CopyLinesCommand
}
from
'
./copyLinesCommand
'
;
import
{
DeleteLinesCommand
}
from
'
./deleteLinesCommand
'
;
...
...
@@ -346,3 +348,39 @@ class InsertLineAfterAction extends HandlerEditorAction {
});
}
}
@
editorAction
export
class
DeleteAllLeftAction
extends
EditorAction
{
constructor
()
{
super
({
id
:
'
deleteAllLeft
'
,
label
:
nls
.
localize
(
'
lines.deleteAllLeft
'
,
"
Delete All Left
"
),
alias
:
'
Delete All Left
'
,
precondition
:
EditorContextKeys
.
Writable
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
TextFocus
,
primary
:
null
,
mac
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
Backspace
}
}
});
}
public
run
(
accessor
:
ServicesAccessor
,
editor
:
ICommonCodeEditor
):
void
{
let
selections
=
editor
.
getSelections
();
let
commands
:
ICommand
[]
=
[];
for
(
let
i
=
0
,
len
=
selections
.
length
;
i
<
len
;
i
++
)
{
let
selection
=
selections
[
i
];
if
(
selection
.
isEmpty
())
{
console
.
log
(
selection
.
startColumn
);
commands
[
i
]
=
new
ReplaceCommand
(
new
Range
(
selection
.
startLineNumber
,
1
,
selection
.
startLineNumber
,
selection
.
startColumn
),
''
);
}
else
{
commands
[
i
]
=
new
ReplaceCommand
(
selection
,
''
);
}
}
editor
.
executeCommands
(
this
.
id
,
commands
);
}
}
src/vs/editor/contrib/linesOperations/test/common/linesOperations.test.ts
0 → 100644
浏览文件 @
05fc8ae1
/*---------------------------------------------------------------------------------------------
* 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
*
as
assert
from
'
assert
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
withMockCodeEditor
}
from
'
vs/editor/test/common/mocks/mockCodeEditor
'
;
import
{
DeleteAllLeftAction
}
from
'
vs/editor/contrib/linesOperations/common/linesOperations
'
;
suite
(
'
Editor Contrib - Line Operations
'
,
()
=>
{
test
(
'
delete all left
'
,
function
()
{
withMockCodeEditor
(
[
'
one
'
,
'
two
'
,
'
three
'
,
'
one two three four
'
],
{},
(
editor
,
cursor
)
=>
{
let
model
=
editor
.
getModel
();
let
joinLinesAction
=
new
DeleteAllLeftAction
();
editor
.
setSelection
(
new
Selection
(
1
,
2
,
1
,
2
));
joinLinesAction
.
run
(
null
,
editor
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
ne
'
,
'
001
'
);
editor
.
setSelections
([
new
Selection
(
2
,
2
,
2
,
2
),
new
Selection
(
3
,
2
,
3
,
2
)]);
joinLinesAction
.
run
(
null
,
editor
);
assert
.
equal
(
model
.
getLineContent
(
2
),
'
wo
'
,
'
002
'
);
assert
.
equal
(
model
.
getLineContent
(
3
),
'
hree
'
,
'
003
'
);
editor
.
setSelections
([
new
Selection
(
4
,
5
,
4
,
5
),
new
Selection
(
4
,
15
,
4
,
15
)]);
joinLinesAction
.
run
(
null
,
editor
);
assert
.
equal
(
model
.
getLineContent
(
4
),
'
four
'
,
'
004
'
);
});
});
});
\ No newline at end of file
src/vs/monaco.d.ts
浏览文件 @
05fc8ae1
...
...
@@ -3406,7 +3406,6 @@ declare module monaco.editor {
DeleteWordRight
:
string
;
DeleteWordStartRight
:
string
;
DeleteWordEndRight
:
string
;
DeleteAllLeft
:
string
;
DeleteAllRight
:
string
;
RemoveSecondaryCursors
:
string
;
CancelSelection
:
string
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录