Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
118e1445
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,发现更多精彩内容 >>
提交
118e1445
编写于
3月 27, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #46208: Recover selection from markers when the undo/redo stack lacks selection information
上级
4f4dc86a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
65 addition
and
8 deletion
+65
-8
src/vs/editor/common/controller/cursor.ts
src/vs/editor/common/controller/cursor.ts
+1
-1
src/vs/editor/common/services/modelServiceImpl.ts
src/vs/editor/common/services/modelServiceImpl.ts
+3
-4
src/vs/editor/test/browser/controller/cursor.test.ts
src/vs/editor/test/browser/controller/cursor.test.ts
+58
-0
src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts
...rkbench/api/electron-browser/mainThreadSaveParticipant.ts
+3
-3
未找到文件。
src/vs/editor/common/controller/cursor.ts
浏览文件 @
118e1445
...
...
@@ -361,7 +361,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
private
_interpretCommandResult
(
cursorState
:
Selection
[]):
void
{
if
(
!
cursorState
||
cursorState
.
length
===
0
)
{
return
;
cursorState
=
this
.
_cursors
.
readSelectionFromMarkers
()
;
}
this
.
_columnSelectData
=
null
;
...
...
src/vs/editor/common/services/modelServiceImpl.ts
浏览文件 @
118e1445
...
...
@@ -13,7 +13,6 @@ import URI from 'vs/base/common/uri';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IMarker
,
IMarkerService
,
MarkerSeverity
}
from
'
vs/platform/markers/common/markers
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
TextModel
,
createTextBuffer
}
from
'
vs/editor/common/model/textModel
'
;
import
{
IMode
,
LanguageIdentifier
}
from
'
vs/editor/common/modes
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
...
...
@@ -398,9 +397,9 @@ export class ModelServiceImpl implements IModelService {
// Otherwise find a diff between the values and update model
model
.
setEOL
(
textBuffer
.
getEOL
()
===
'
\r\n
'
?
EndOfLineSequence
.
CRLF
:
EndOfLineSequence
.
LF
);
model
.
pushEditOperations
(
[
new
Selection
(
1
,
1
,
1
,
1
)
],
[],
ModelServiceImpl
.
_computeEdits
(
model
,
textBuffer
),
(
inverseEditOperations
:
IIdentifiedSingleEditOperation
[])
=>
[
new
Selection
(
1
,
1
,
1
,
1
)
]
(
inverseEditOperations
:
IIdentifiedSingleEditOperation
[])
=>
[]
);
}
...
...
@@ -451,7 +450,7 @@ export class ModelServiceImpl implements IModelService {
newRange
=
new
Range
(
1
,
1
,
textBufferLineCount
,
1
+
textBuffer
.
getLineLength
(
textBufferLineCount
));
}
return
[
EditOperation
.
replace
(
oldRange
,
textBuffer
.
getValueInRange
(
newRange
,
EndOfLinePreference
.
TextDefined
))];
return
[
EditOperation
.
replace
Move
(
oldRange
,
textBuffer
.
getValueInRange
(
newRange
,
EndOfLinePreference
.
TextDefined
))];
}
public
createModel
(
value
:
string
|
ITextBufferFactory
,
modeOrPromise
:
TPromise
<
IMode
>
|
IMode
,
resource
:
URI
,
isForSimpleWidget
:
boolean
=
false
):
ITextModel
{
...
...
src/vs/editor/test/browser/controller/cursor.test.ts
浏览文件 @
118e1445
...
...
@@ -1219,6 +1219,64 @@ suite('Editor Controller - Regression tests', () => {
model
.
dispose
();
});
test
(
'
issue #46208: Allow empty selections in the undo/redo stack
'
,
()
=>
{
let
model
=
TextModel
.
createFromString
(
''
);
withTestCodeEditor
(
null
,
{
model
:
model
},
(
editor
,
cursor
)
=>
{
cursorCommand
(
cursor
,
H
.
Type
,
{
text
:
'
Hello
'
},
'
keyboard
'
);
cursorCommand
(
cursor
,
H
.
Type
,
{
text
:
'
'
},
'
keyboard
'
);
cursorCommand
(
cursor
,
H
.
Type
,
{
text
:
'
world
'
},
'
keyboard
'
);
cursorCommand
(
cursor
,
H
.
Type
,
{
text
:
'
'
},
'
keyboard
'
);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Hello world
'
);
assertCursor
(
cursor
,
new
Position
(
1
,
13
));
moveLeft
(
cursor
);
moveRight
(
cursor
);
model
.
pushEditOperations
([],
[
EditOperation
.
replaceMove
(
new
Range
(
1
,
12
,
1
,
13
),
''
)],
()
=>
[]);
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Hello world
'
);
assertCursor
(
cursor
,
new
Position
(
1
,
12
));
cursorCommand
(
cursor
,
H
.
Undo
,
{});
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Hello world
'
);
assertCursor
(
cursor
,
new
Position
(
1
,
13
));
cursorCommand
(
cursor
,
H
.
Undo
,
{});
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Hello world
'
);
assertCursor
(
cursor
,
new
Position
(
1
,
12
));
cursorCommand
(
cursor
,
H
.
Undo
,
{});
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Hello
'
);
assertCursor
(
cursor
,
new
Position
(
1
,
6
));
cursorCommand
(
cursor
,
H
.
Undo
,
{});
assert
.
equal
(
model
.
getLineContent
(
1
),
''
);
assertCursor
(
cursor
,
new
Position
(
1
,
1
));
cursorCommand
(
cursor
,
H
.
Redo
,
{});
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Hello
'
);
assertCursor
(
cursor
,
new
Position
(
1
,
6
));
cursorCommand
(
cursor
,
H
.
Redo
,
{});
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Hello world
'
);
assertCursor
(
cursor
,
new
Position
(
1
,
12
));
cursorCommand
(
cursor
,
H
.
Redo
,
{});
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Hello world
'
);
assertCursor
(
cursor
,
new
Position
(
1
,
13
));
cursorCommand
(
cursor
,
H
.
Redo
,
{});
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Hello world
'
);
assertCursor
(
cursor
,
new
Position
(
1
,
12
));
cursorCommand
(
cursor
,
H
.
Redo
,
{});
assert
.
equal
(
model
.
getLineContent
(
1
),
'
Hello world
'
);
assertCursor
(
cursor
,
new
Position
(
1
,
12
));
});
model
.
dispose
();
});
test
(
'
bug #16815:Shift+Tab doesn
\'
t go back to tabstop
'
,
()
=>
{
let
mode
=
new
OnEnterMode
(
IndentAction
.
IndentOutdent
);
let
model
=
TextModel
.
createFromString
(
...
...
src/vs/workbench/api/electron-browser/mainThreadSaveParticipant.ts
浏览文件 @
118e1445
...
...
@@ -50,7 +50,7 @@ class TrimWhitespaceParticipant implements ISaveParticipantParticipant {
}
private
doTrimTrailingWhitespace
(
model
:
ITextModel
,
isAutoSaved
:
boolean
):
void
{
let
prevSelection
:
Selection
[]
=
[
new
Selection
(
1
,
1
,
1
,
1
)
];
let
prevSelection
:
Selection
[]
=
[];
const
cursors
:
Position
[]
=
[];
let
editor
=
findEditor
(
model
,
this
.
codeEditorService
);
...
...
@@ -114,7 +114,7 @@ export class FinalNewLineParticipant implements ISaveParticipantParticipant {
return
;
}
let
prevSelection
:
Selection
[]
=
[
new
Selection
(
1
,
1
,
1
,
1
)
];
let
prevSelection
:
Selection
[]
=
[];
const
editor
=
findEditor
(
model
,
this
.
codeEditorService
);
if
(
editor
)
{
prevSelection
=
editor
.
getSelections
();
...
...
@@ -151,7 +151,7 @@ export class TrimFinalNewLinesParticipant implements ISaveParticipantParticipant
return
;
}
let
prevSelection
:
Selection
[]
=
[
new
Selection
(
1
,
1
,
1
,
1
)
];
let
prevSelection
:
Selection
[]
=
[];
const
editor
=
findEditor
(
model
,
this
.
codeEditorService
);
if
(
editor
)
{
prevSelection
=
editor
.
getSelections
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录