Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7cfc1943
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,发现更多精彩内容 >>
未验证
提交
7cfc1943
编写于
1月 15, 2020
作者:
A
Alexandru Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #85712
上级
5bfd23cd
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
206 addition
and
166 deletion
+206
-166
src/vs/editor/common/commands/replaceCommand.ts
src/vs/editor/common/commands/replaceCommand.ts
+4
-2
src/vs/editor/common/controller/cursor.ts
src/vs/editor/common/controller/cursor.ts
+5
-5
src/vs/editor/common/controller/cursorTypeOperations.ts
src/vs/editor/common/controller/cursorTypeOperations.ts
+1
-1
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+2
-2
src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts
...itor/contrib/linesOperations/test/linesOperations.test.ts
+157
-147
src/vs/editor/test/browser/commands/shiftCommand.test.ts
src/vs/editor/test/browser/commands/shiftCommand.test.ts
+2
-1
src/vs/editor/test/browser/commands/trimTrailingWhitespaceCommand.test.ts
...st/browser/commands/trimTrailingWhitespaceCommand.test.ts
+2
-1
src/vs/editor/test/browser/controller/cursor.test.ts
src/vs/editor/test/browser/controller/cursor.test.ts
+25
-1
src/vs/editor/test/browser/testCommand.ts
src/vs/editor/test/browser/testCommand.ts
+6
-4
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+2
-2
未找到文件。
src/vs/editor/common/commands/replaceCommand.ts
浏览文件 @
7cfc1943
...
...
@@ -122,17 +122,19 @@ export class ReplaceCommandThatPreservesSelection implements ICommand {
private
readonly
_range
:
Range
;
private
readonly
_text
:
string
;
private
readonly
_initialSelection
:
Selection
;
private
readonly
_forceMoveMarkers
:
boolean
;
private
_selectionId
:
string
|
null
;
constructor
(
editRange
:
Range
,
text
:
string
,
initialSelection
:
Selection
)
{
constructor
(
editRange
:
Range
,
text
:
string
,
initialSelection
:
Selection
,
forceMoveMarkers
:
boolean
=
false
)
{
this
.
_range
=
editRange
;
this
.
_text
=
text
;
this
.
_initialSelection
=
initialSelection
;
this
.
_forceMoveMarkers
=
forceMoveMarkers
;
this
.
_selectionId
=
null
;
}
public
getEditOperations
(
model
:
ITextModel
,
builder
:
IEditOperationBuilder
):
void
{
builder
.
add
EditOperation
(
this
.
_range
,
this
.
_text
);
builder
.
add
TrackedEditOperation
(
this
.
_range
,
this
.
_text
,
this
.
_forceMoveMarkers
);
this
.
_selectionId
=
builder
.
trackSelection
(
this
.
_initialSelection
);
}
...
...
src/vs/editor/common/controller/cursor.ts
浏览文件 @
7cfc1943
...
...
@@ -727,7 +727,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
case
H
.
Paste
:
cursorChangeReason
=
CursorChangeReason
.
Paste
;
this
.
_paste
(
<
string
>
payload
.
text
,
<
boolean
>
payload
.
pasteOnNewLine
,
<
string
[]
>
payload
.
multicursorText
);
this
.
_paste
(
<
string
>
payload
.
text
,
<
boolean
>
payload
.
pasteOnNewLine
,
<
string
[]
>
payload
.
multicursorText
||
[]
);
break
;
case
H
.
Cut
:
...
...
@@ -1000,7 +1000,7 @@ class CommandExecutor {
let
operations
:
IIdentifiedSingleEditOperation
[]
=
[];
let
operationMinor
=
0
;
const
addEditOperation
=
(
selection
:
Range
,
text
:
string
|
null
)
=>
{
const
addEditOperation
=
(
selection
:
Range
,
text
:
string
|
null
,
forceMoveMarkers
:
boolean
=
false
)
=>
{
if
(
selection
.
isEmpty
()
&&
text
===
''
)
{
// This command wants to add a no-op => no thank you
return
;
...
...
@@ -1012,15 +1012,15 @@ class CommandExecutor {
},
range
:
selection
,
text
:
text
,
forceMoveMarkers
:
f
alse
,
forceMoveMarkers
:
f
orceMoveMarkers
,
isAutoWhitespaceEdit
:
command
.
insertsAutoWhitespace
});
};
let
hadTrackedEditOperation
=
false
;
const
addTrackedEditOperation
=
(
selection
:
Range
,
text
:
string
|
null
)
=>
{
const
addTrackedEditOperation
=
(
selection
:
Range
,
text
:
string
|
null
,
forceMoveMarkers
?:
boolean
)
=>
{
hadTrackedEditOperation
=
true
;
addEditOperation
(
selection
,
text
);
addEditOperation
(
selection
,
text
,
forceMoveMarkers
);
};
const
trackSelection
=
(
selection
:
Selection
,
trackPreviousOnEmpty
?:
boolean
)
=>
{
...
...
src/vs/editor/common/controller/cursorTypeOperations.ts
浏览文件 @
7cfc1943
...
...
@@ -94,7 +94,7 @@ export class TypeOperations {
if
(
pasteOnNewLine
)
{
// Paste entire line at the beginning of line
let
typeSelection
=
new
Range
(
position
.
lineNumber
,
1
,
position
.
lineNumber
,
1
);
commands
[
i
]
=
new
ReplaceCommandThatPreservesSelection
(
typeSelection
,
text
,
selection
);
commands
[
i
]
=
new
ReplaceCommandThatPreservesSelection
(
typeSelection
,
text
,
selection
,
true
);
}
else
{
commands
[
i
]
=
new
ReplaceCommand
(
selection
,
text
);
}
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
7cfc1943
...
...
@@ -22,7 +22,7 @@ export interface IEditOperationBuilder {
* @param range The range to replace (delete). May be empty to represent a simple insert.
* @param text The text to replace with. May be null to represent a simple delete.
*/
addEditOperation
(
range
:
Range
,
text
:
string
|
null
):
void
;
addEditOperation
(
range
:
Range
,
text
:
string
|
null
,
forceMoveMarkers
?:
boolean
):
void
;
/**
* Add a new edit operation (a replace operation).
...
...
@@ -30,7 +30,7 @@ export interface IEditOperationBuilder {
* @param range The range to replace (delete). May be empty to represent a simple insert.
* @param text The text to replace with. May be null to represent a simple delete.
*/
addTrackedEditOperation
(
range
:
Range
,
text
:
string
|
null
):
void
;
addTrackedEditOperation
(
range
:
Range
,
text
:
string
|
null
,
forceMoveMarkers
?:
boolean
):
void
;
/**
* Track `selection` when applying edit operations.
...
...
src/vs/editor/contrib/linesOperations/test/linesOperations.test.ts
浏览文件 @
7cfc1943
此差异已折叠。
点击以展开。
src/vs/editor/test/browser/commands/shiftCommand.test.ts
浏览文件 @
7cfc1943
...
...
@@ -22,7 +22,8 @@ import { EditorAutoIndentStrategy } from 'vs/editor/common/config/editorOptions'
export
function
createSingleEditOp
(
text
:
string
,
positionLineNumber
:
number
,
positionColumn
:
number
,
selectionLineNumber
:
number
=
positionLineNumber
,
selectionColumn
:
number
=
positionColumn
):
IIdentifiedSingleEditOperation
{
return
{
range
:
new
Range
(
selectionLineNumber
,
selectionColumn
,
positionLineNumber
,
positionColumn
),
text
:
text
text
:
text
,
forceMoveMarkers
:
false
};
}
...
...
src/vs/editor/test/browser/commands/trimTrailingWhitespaceCommand.test.ts
浏览文件 @
7cfc1943
...
...
@@ -28,7 +28,8 @@ function createInsertDeleteSingleEditOp(text: string | null, positionLineNumber:
export
function
createSingleEditOp
(
text
:
string
|
null
,
positionLineNumber
:
number
,
positionColumn
:
number
,
selectionLineNumber
:
number
=
positionLineNumber
,
selectionColumn
:
number
=
positionColumn
):
IIdentifiedSingleEditOperation
{
return
{
range
:
new
Range
(
selectionLineNumber
,
selectionColumn
,
positionLineNumber
,
positionColumn
),
text
:
text
text
:
text
,
forceMoveMarkers
:
false
};
}
...
...
src/vs/editor/test/browser/controller/cursor.test.ts
浏览文件 @
7cfc1943
...
...
@@ -2279,6 +2279,30 @@ suite('Editor Controller - Regression tests', () => {
model
.
dispose
();
});
test
(
'
issue #85712: Paste line moves cursor to start of current line rather than start of next line
'
,
()
=>
{
let
model
=
createTextModel
(
[
'
abc123
'
,
''
].
join
(
'
\n
'
)
);
withTestCodeEditor
(
null
,
{
model
:
model
},
(
editor
,
cursor
)
=>
{
editor
.
setSelections
([
new
Selection
(
2
,
1
,
2
,
1
)
]);
cursorCommand
(
cursor
,
H
.
Paste
,
{
text
:
'
something
\n
'
,
pasteOnNewLine
:
true
});
assert
.
equal
(
model
.
getValue
(),
[
'
abc123
'
,
'
something
'
,
''
].
join
(
'
\n
'
));
assertCursor
(
cursor
,
new
Position
(
3
,
1
));
});
model
.
dispose
();
});
});
suite
(
'
Editor Controller - Cursor Configuration
'
,
()
=>
{
...
...
@@ -2636,7 +2660,7 @@ suite('Editor Controller - Cursor Configuration', () => {
''
,
'
}
'
,
].
join
(
'
\n
'
));
assertCursor
(
cursor
,
new
Position
(
4
,
1
));
assertCursor
(
cursor
,
new
Position
(
5
,
1
));
});
model
.
dispose
();
...
...
src/vs/editor/test/browser/testCommand.ts
浏览文件 @
7cfc1943
...
...
@@ -50,17 +50,19 @@ export function testCommand(
export
function
getEditOperation
(
model
:
ITextModel
,
command
:
ICommand
):
IIdentifiedSingleEditOperation
[]
{
let
operations
:
IIdentifiedSingleEditOperation
[]
=
[];
let
editOperationBuilder
:
IEditOperationBuilder
=
{
addEditOperation
:
(
range
:
Range
,
text
:
string
)
=>
{
addEditOperation
:
(
range
:
Range
,
text
:
string
,
forceMoveMarkers
:
boolean
=
false
)
=>
{
operations
.
push
({
range
:
range
,
text
:
text
text
:
text
,
forceMoveMarkers
:
forceMoveMarkers
});
},
addTrackedEditOperation
:
(
range
:
Range
,
text
:
string
)
=>
{
addTrackedEditOperation
:
(
range
:
Range
,
text
:
string
,
forceMoveMarkers
:
boolean
=
false
)
=>
{
operations
.
push
({
range
:
range
,
text
:
text
text
:
text
,
forceMoveMarkers
:
forceMoveMarkers
});
},
...
...
src/vs/monaco.d.ts
浏览文件 @
7cfc1943
...
...
@@ -1906,14 +1906,14 @@ declare namespace monaco.editor {
* @param range The range to replace (delete). May be empty to represent a simple insert.
* @param text The text to replace with. May be null to represent a simple delete.
*/
addEditOperation
(
range
:
Range
,
text
:
string
|
null
):
void
;
addEditOperation
(
range
:
Range
,
text
:
string
|
null
,
forceMoveMarkers
?:
boolean
):
void
;
/**
* Add a new edit operation (a replace operation).
* The inverse edits will be accessible in `ICursorStateComputerData.getInverseEditOperations()`
* @param range The range to replace (delete). May be empty to represent a simple insert.
* @param text The text to replace with. May be null to represent a simple delete.
*/
addTrackedEditOperation
(
range
:
Range
,
text
:
string
|
null
):
void
;
addTrackedEditOperation
(
range
:
Range
,
text
:
string
|
null
,
forceMoveMarkers
?:
boolean
):
void
;
/**
* Track `selection` when applying edit operations.
* A best effort will be made to not grow/expand the selection.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录