Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7b1da3a3
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,体验更适合开发者的 AI 搜索 >>
提交
7b1da3a3
编写于
11月 25, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add IBulkEditOptions#token,
https://github.com/microsoft/vscode/issues/111281
上级
92729027
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
27 addition
and
4 deletion
+27
-4
src/vs/editor/browser/services/bulkEditService.ts
src/vs/editor/browser/services/bulkEditService.ts
+2
-0
src/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits.ts
src/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits.ts
+5
-0
src/vs/workbench/contrib/bulkEdit/browser/bulkEditService.ts
src/vs/workbench/contrib/bulkEdit/browser/bulkEditService.ts
+8
-4
src/vs/workbench/contrib/bulkEdit/browser/bulkFileEdits.ts
src/vs/workbench/contrib/bulkEdit/browser/bulkFileEdits.ts
+7
-0
src/vs/workbench/contrib/bulkEdit/browser/bulkTextEdits.ts
src/vs/workbench/contrib/bulkEdit/browser/bulkTextEdits.ts
+5
-0
未找到文件。
src/vs/editor/browser/services/bulkEditService.ts
浏览文件 @
7b1da3a3
...
...
@@ -11,6 +11,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
isObject
}
from
'
vs/base/common/types
'
;
import
{
UndoRedoSource
}
from
'
vs/platform/undoRedo/common/undoRedo
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
export
const
IBulkEditService
=
createDecorator
<
IBulkEditService
>
(
'
IWorkspaceEditService
'
);
...
...
@@ -66,6 +67,7 @@ export class ResourceFileEdit extends ResourceEdit {
export
interface
IBulkEditOptions
{
editor
?:
ICodeEditor
;
progress
?:
IProgress
<
IProgressStep
>
;
token
?:
CancellationToken
;
showPreview
?:
boolean
;
label
?:
string
;
quotableLabel
?:
string
;
...
...
src/vs/workbench/contrib/bulkEdit/browser/bulkCellEdits.ts
浏览文件 @
7b1da3a3
...
...
@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
groupBy
}
from
'
vs/base/common/arrays
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
compare
}
from
'
vs/base/common/strings
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
ResourceEdit
}
from
'
vs/editor/browser/services/bulkEditService
'
;
...
...
@@ -31,6 +32,7 @@ export class BulkCellEdits {
private
readonly
_undoRedoGroup
:
UndoRedoGroup
,
undoRedoSource
:
UndoRedoSource
|
undefined
,
private
readonly
_progress
:
IProgress
<
void
>
,
private
readonly
_token
:
CancellationToken
,
private
readonly
_edits
:
ResourceNotebookCellEdit
[],
@
INotebookEditorModelResolverService
private
readonly
_notebookModelService
:
INotebookEditorModelResolverService
,
)
{
}
...
...
@@ -40,6 +42,9 @@ export class BulkCellEdits {
const
editsByNotebook
=
groupBy
(
this
.
_edits
,
(
a
,
b
)
=>
compare
(
a
.
resource
.
toString
(),
b
.
resource
.
toString
()));
for
(
let
group
of
editsByNotebook
)
{
if
(
this
.
_token
.
isCancellationRequested
)
{
break
;
}
const
[
first
]
=
group
;
const
ref
=
await
this
.
_notebookModelService
.
resolve
(
first
.
resource
);
...
...
src/vs/workbench/contrib/bulkEdit/browser/bulkEditService.ts
浏览文件 @
7b1da3a3
...
...
@@ -18,6 +18,7 @@ import { BulkFileEdits } from 'vs/workbench/contrib/bulkEdit/browser/bulkFileEdi
import
{
BulkCellEdits
,
ResourceNotebookCellEdit
}
from
'
vs/workbench/contrib/bulkEdit/browser/bulkCellEdits
'
;
import
{
UndoRedoGroup
,
UndoRedoSource
}
from
'
vs/platform/undoRedo/common/undoRedo
'
;
import
{
LinkedList
}
from
'
vs/base/common/linkedList
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
class
BulkEdit
{
...
...
@@ -25,6 +26,7 @@ class BulkEdit {
private
readonly
_label
:
string
|
undefined
,
private
readonly
_editor
:
ICodeEditor
|
undefined
,
private
readonly
_progress
:
IProgress
<
IProgressStep
>
,
private
readonly
_token
:
CancellationToken
,
private
readonly
_edits
:
ResourceEdit
[],
private
readonly
_undoRedoGroup
:
UndoRedoGroup
,
private
readonly
_undoRedoSource
:
UndoRedoSource
|
undefined
,
...
...
@@ -82,19 +84,19 @@ class BulkEdit {
private
async
_performFileEdits
(
edits
:
ResourceFileEdit
[],
undoRedoGroup
:
UndoRedoGroup
,
undoRedoSource
:
UndoRedoSource
|
undefined
,
progress
:
IProgress
<
void
>
)
{
this
.
_logService
.
debug
(
'
_performFileEdits
'
,
JSON
.
stringify
(
edits
));
const
model
=
this
.
_instaService
.
createInstance
(
BulkFileEdits
,
this
.
_label
||
localize
(
'
workspaceEdit
'
,
"
Workspace Edit
"
),
undoRedoGroup
,
undoRedoSource
,
progress
,
edits
);
const
model
=
this
.
_instaService
.
createInstance
(
BulkFileEdits
,
this
.
_label
||
localize
(
'
workspaceEdit
'
,
"
Workspace Edit
"
),
undoRedoGroup
,
undoRedoSource
,
progress
,
this
.
_token
,
edits
);
await
model
.
apply
();
}
private
async
_performTextEdits
(
edits
:
ResourceTextEdit
[],
undoRedoGroup
:
UndoRedoGroup
,
undoRedoSource
:
UndoRedoSource
|
undefined
,
progress
:
IProgress
<
void
>
):
Promise
<
void
>
{
this
.
_logService
.
debug
(
'
_performTextEdits
'
,
JSON
.
stringify
(
edits
));
const
model
=
this
.
_instaService
.
createInstance
(
BulkTextEdits
,
this
.
_label
||
localize
(
'
workspaceEdit
'
,
"
Workspace Edit
"
),
this
.
_editor
,
undoRedoGroup
,
undoRedoSource
,
progress
,
edits
);
const
model
=
this
.
_instaService
.
createInstance
(
BulkTextEdits
,
this
.
_label
||
localize
(
'
workspaceEdit
'
,
"
Workspace Edit
"
),
this
.
_editor
,
undoRedoGroup
,
undoRedoSource
,
progress
,
this
.
_token
,
edits
);
await
model
.
apply
();
}
private
async
_performCellEdits
(
edits
:
ResourceNotebookCellEdit
[],
undoRedoGroup
:
UndoRedoGroup
,
undoRedoSource
:
UndoRedoSource
|
undefined
,
progress
:
IProgress
<
void
>
):
Promise
<
void
>
{
this
.
_logService
.
debug
(
'
_performCellEdits
'
,
JSON
.
stringify
(
edits
));
const
model
=
this
.
_instaService
.
createInstance
(
BulkCellEdits
,
undoRedoGroup
,
undoRedoSource
,
progress
,
edits
);
const
model
=
this
.
_instaService
.
createInstance
(
BulkCellEdits
,
undoRedoGroup
,
undoRedoSource
,
progress
,
this
.
_token
,
edits
);
await
model
.
apply
();
}
}
...
...
@@ -170,7 +172,9 @@ export class BulkEditService implements IBulkEditService {
const
bulkEdit
=
this
.
_instaService
.
createInstance
(
BulkEdit
,
options
?.
quotableLabel
||
options
?.
label
,
codeEditor
,
options
?.
progress
??
Progress
.
None
,
codeEditor
,
options
?.
progress
??
Progress
.
None
,
options
?.
token
??
CancellationToken
.
None
,
edits
,
undoRedoGroup
,
options
?.
undoRedoSource
...
...
src/vs/workbench/contrib/bulkEdit/browser/bulkFileEdits.ts
浏览文件 @
7b1da3a3
...
...
@@ -16,6 +16,7 @@ import { ILogService } from 'vs/platform/log/common/log';
import
{
VSBuffer
}
from
'
vs/base/common/buffer
'
;
import
{
ResourceFileEdit
}
from
'
vs/editor/browser/services/bulkEditService
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
interface
IFileOperationUndoRedoInfo
{
undoRedoGroupId
?:
number
;
...
...
@@ -227,6 +228,7 @@ export class BulkFileEdits {
private
readonly
_undoRedoGroup
:
UndoRedoGroup
,
private
readonly
_undoRedoSource
:
UndoRedoSource
|
undefined
,
private
readonly
_progress
:
IProgress
<
void
>
,
private
readonly
_token
:
CancellationToken
,
private
readonly
_edits
:
ResourceFileEdit
[],
@
IInstantiationService
private
readonly
_instaService
:
IInstantiationService
,
@
IUndoRedoService
private
readonly
_undoRedoService
:
IUndoRedoService
,
...
...
@@ -236,6 +238,11 @@ export class BulkFileEdits {
const
undoOperations
:
IFileOperation
[]
=
[];
const
undoRedoInfo
=
{
undoRedoGroupId
:
this
.
_undoRedoGroup
.
id
};
for
(
const
edit
of
this
.
_edits
)
{
if
(
this
.
_token
.
isCancellationRequested
)
{
break
;
}
this
.
_progress
.
report
(
undefined
);
const
options
=
edit
.
options
||
{};
...
...
src/vs/workbench/contrib/bulkEdit/browser/bulkTextEdits.ts
浏览文件 @
7b1da3a3
...
...
@@ -19,6 +19,7 @@ import { SingleModelEditStackElement, MultiModelEditStackElement } from 'vs/edit
import
{
ResourceMap
}
from
'
vs/base/common/map
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
ResourceTextEdit
}
from
'
vs/editor/browser/services/bulkEditService
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
type
ValidationResult
=
{
canApply
:
true
}
|
{
canApply
:
false
,
reason
:
URI
};
...
...
@@ -136,6 +137,7 @@ export class BulkTextEdits {
private
readonly
_undoRedoGroup
:
UndoRedoGroup
,
private
readonly
_undoRedoSource
:
UndoRedoSource
|
undefined
,
private
readonly
_progress
:
IProgress
<
void
>
,
private
readonly
_token
:
CancellationToken
,
edits
:
ResourceTextEdit
[],
@
IEditorWorkerService
private
readonly
_editorWorker
:
IEditorWorkerService
,
@
IModelService
private
readonly
_modelService
:
IModelService
,
...
...
@@ -223,6 +225,9 @@ export class BulkTextEdits {
this
.
_validateBeforePrepare
();
const
tasks
=
await
this
.
_createEditsTasks
();
if
(
this
.
_token
.
isCancellationRequested
)
{
return
;
}
try
{
const
validation
=
this
.
_validateTasks
(
tasks
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录