Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
92a0f560
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,发现更多精彩内容 >>
未验证
提交
92a0f560
编写于
9月 23, 2020
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add an ordering for grouped undo/redo elements (#101789)
上级
83f8f52c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
17 deletion
+52
-17
src/vs/platform/undoRedo/common/undoRedo.ts
src/vs/platform/undoRedo/common/undoRedo.ts
+9
-0
src/vs/platform/undoRedo/common/undoRedoService.ts
src/vs/platform/undoRedo/common/undoRedoService.ts
+43
-17
未找到文件。
src/vs/platform/undoRedo/common/undoRedo.ts
浏览文件 @
92a0f560
...
...
@@ -64,9 +64,18 @@ export class UndoRedoGroup {
private
static
_ID
=
0
;
public
readonly
id
:
number
;
private
order
:
number
;
constructor
()
{
this
.
id
=
UndoRedoGroup
.
_ID
++
;
this
.
order
=
1
;
}
public
nextOrder
():
number
{
if
(
this
.
id
===
0
)
{
return
0
;
}
return
this
.
order
++
;
}
public
static
None
=
new
UndoRedoGroup
();
...
...
src/vs/platform/undoRedo/common/undoRedoService.ts
浏览文件 @
92a0f560
...
...
@@ -33,9 +33,10 @@ class ResourceStackElement {
public
readonly
resourceLabels
:
string
[];
public
readonly
strResources
:
string
[];
public
readonly
groupId
:
number
;
public
readonly
groupOrder
:
number
;
public
isValid
:
boolean
;
constructor
(
actual
:
IUndoRedoElement
,
resourceLabel
:
string
,
strResource
:
string
,
groupId
:
number
)
{
constructor
(
actual
:
IUndoRedoElement
,
resourceLabel
:
string
,
strResource
:
string
,
groupId
:
number
,
groupOrder
:
number
)
{
this
.
actual
=
actual
;
this
.
label
=
actual
.
label
;
this
.
resourceLabel
=
resourceLabel
;
...
...
@@ -43,6 +44,7 @@ class ResourceStackElement {
this
.
resourceLabels
=
[
this
.
resourceLabel
];
this
.
strResources
=
[
this
.
strResource
];
this
.
groupId
=
groupId
;
this
.
groupOrder
=
groupOrder
;
this
.
isValid
=
true
;
}
...
...
@@ -127,15 +129,17 @@ class WorkspaceStackElement {
public
readonly
resourceLabels
:
string
[];
public
readonly
strResources
:
string
[];
public
readonly
groupId
:
number
;
public
readonly
groupOrder
:
number
;
public
removedResources
:
RemovedResources
|
null
;
public
invalidatedResources
:
RemovedResources
|
null
;
constructor
(
actual
:
IWorkspaceUndoRedoElement
,
resourceLabels
:
string
[],
strResources
:
string
[],
groupId
:
number
)
{
constructor
(
actual
:
IWorkspaceUndoRedoElement
,
resourceLabels
:
string
[],
strResources
:
string
[],
groupId
:
number
,
groupOrder
:
number
)
{
this
.
actual
=
actual
;
this
.
label
=
actual
.
label
;
this
.
resourceLabels
=
resourceLabels
;
this
.
strResources
=
strResources
;
this
.
groupId
=
groupId
;
this
.
groupOrder
=
groupOrder
;
this
.
removedResources
=
null
;
this
.
invalidatedResources
=
null
;
}
...
...
@@ -497,7 +501,7 @@ export class UndoRedoService implements IUndoRedoService {
if
(
element
.
type
===
UndoRedoElementType
.
Resource
)
{
const
resourceLabel
=
getResourceLabel
(
element
.
resource
);
const
strResource
=
this
.
getUriComparisonKey
(
element
.
resource
);
this
.
_pushElement
(
new
ResourceStackElement
(
element
,
resourceLabel
,
strResource
,
group
.
id
));
this
.
_pushElement
(
new
ResourceStackElement
(
element
,
resourceLabel
,
strResource
,
group
.
id
,
group
.
nextOrder
()
));
}
else
{
const
seen
=
new
Set
<
string
>
();
const
resourceLabels
:
string
[]
=
[];
...
...
@@ -515,9 +519,9 @@ export class UndoRedoService implements IUndoRedoService {
}
if
(
resourceLabels
.
length
===
1
)
{
this
.
_pushElement
(
new
ResourceStackElement
(
element
,
resourceLabels
[
0
],
strResources
[
0
],
group
.
id
));
this
.
_pushElement
(
new
ResourceStackElement
(
element
,
resourceLabels
[
0
],
strResources
[
0
],
group
.
id
,
group
.
nextOrder
()
));
}
else
{
this
.
_pushElement
(
new
WorkspaceStackElement
(
element
,
resourceLabels
,
strResources
,
group
.
id
));
this
.
_pushElement
(
new
WorkspaceStackElement
(
element
,
resourceLabels
,
strResources
,
group
.
id
,
group
.
nextOrder
()
));
}
}
if
(
DEBUG
)
{
...
...
@@ -561,7 +565,7 @@ export class UndoRedoService implements IUndoRedoService {
for
(
const
_element
of
individualArr
)
{
const
resourceLabel
=
getResourceLabel
(
_element
.
resource
);
const
strResource
=
this
.
getUriComparisonKey
(
_element
.
resource
);
const
element
=
new
ResourceStackElement
(
_element
,
resourceLabel
,
strResource
,
0
);
const
element
=
new
ResourceStackElement
(
_element
,
resourceLabel
,
strResource
,
0
,
0
);
individualMap
.
set
(
element
.
strResource
,
element
);
}
...
...
@@ -580,7 +584,7 @@ export class UndoRedoService implements IUndoRedoService {
for
(
const
_element
of
individualArr
)
{
const
resourceLabel
=
getResourceLabel
(
_element
.
resource
);
const
strResource
=
this
.
getUriComparisonKey
(
_element
.
resource
);
const
element
=
new
ResourceStackElement
(
_element
,
resourceLabel
,
strResource
,
0
);
const
element
=
new
ResourceStackElement
(
_element
,
resourceLabel
,
strResource
,
0
,
0
);
individualMap
.
set
(
element
.
strResource
,
element
);
}
...
...
@@ -985,16 +989,27 @@ export class UndoRedoService implements IUndoRedoService {
if
(
!
groupId
)
{
return
;
}
// find another element with the same groupId ready to be undone
// find another element with the same groupId and with the highest groupOrder ready to be undone
let
matchedElement
:
StackElement
|
null
=
null
;
let
matchedStrResource
:
string
|
null
=
null
;
for
(
const
[
strResource
,
editStack
]
of
this
.
_editStacks
)
{
const
pastElement
=
editStack
.
getClosestPastElement
();
if
(
!
pastElement
)
{
const
candidate
=
editStack
.
getClosestPastElement
();
if
(
!
candidate
)
{
continue
;
}
if
(
pastElement
.
groupId
===
groupId
)
{
return
this
.
undo
(
strResource
);
if
(
candidate
.
groupId
===
groupId
)
{
if
(
!
matchedElement
||
candidate
.
groupOrder
>
matchedElement
.
groupOrder
)
{
matchedElement
=
candidate
;
matchedStrResource
=
strResource
;
}
}
}
if
(
matchedStrResource
)
{
return
this
.
undo
(
matchedStrResource
);
}
}
public
undo
(
resource
:
URI
|
string
):
Promise
<
void
>
|
void
{
...
...
@@ -1179,16 +1194,27 @@ export class UndoRedoService implements IUndoRedoService {
if
(
!
groupId
)
{
return
;
}
// find another element with the same groupId ready to be redone
// find another element with the same groupId and with the lowest groupOrder ready to be redone
let
matchedElement
:
StackElement
|
null
=
null
;
let
matchedStrResource
:
string
|
null
=
null
;
for
(
const
[
strResource
,
editStack
]
of
this
.
_editStacks
)
{
const
futureElement
=
editStack
.
getClosestFutureElement
();
if
(
!
futureElement
)
{
const
candidate
=
editStack
.
getClosestFutureElement
();
if
(
!
candidate
)
{
continue
;
}
if
(
futureElement
.
groupId
===
groupId
)
{
return
this
.
redo
(
strResource
);
if
(
candidate
.
groupId
===
groupId
)
{
if
(
!
matchedElement
||
candidate
.
groupOrder
<
matchedElement
.
groupOrder
)
{
matchedElement
=
candidate
;
matchedStrResource
=
strResource
;
}
}
}
if
(
matchedStrResource
)
{
return
this
.
redo
(
matchedStrResource
);
}
}
public
redo
(
resource
:
URI
|
string
):
Promise
<
void
>
|
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录