Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
5fd42b76
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 搜索 >>
提交
5fd42b76
编写于
1月 26, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
editor - add group to revert()
上级
df8cdd94
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
43 addition
and
33 deletion
+43
-33
src/vs/workbench/browser/parts/editor/editorActions.ts
src/vs/workbench/browser/parts/editor/editorActions.ts
+2
-2
src/vs/workbench/browser/parts/editor/editorGroupView.ts
src/vs/workbench/browser/parts/editor/editorGroupView.ts
+3
-3
src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
+2
-2
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+22
-8
src/vs/workbench/common/editor/untitledTextEditorInput.ts
src/vs/workbench/common/editor/untitledTextEditorInput.ts
+1
-1
src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts
...rkbench/contrib/customEditor/browser/customEditorInput.ts
+1
-1
src/vs/workbench/contrib/files/common/editors/fileEditorInput.ts
...workbench/contrib/files/common/editors/fileEditorInput.ts
+1
-5
src/vs/workbench/contrib/files/test/browser/fileEditorInput.test.ts
...kbench/contrib/files/test/browser/fileEditorInput.test.ts
+1
-1
src/vs/workbench/contrib/search/browser/searchEditorInput.ts
src/vs/workbench/contrib/search/browser/searchEditorInput.ts
+3
-3
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+1
-1
src/vs/workbench/services/editor/test/browser/editorService.test.ts
...kbench/services/editor/test/browser/editorService.test.ts
+1
-1
src/vs/workbench/services/textfile/browser/textFileService.ts
...vs/workbench/services/textfile/browser/textFileService.ts
+1
-1
src/vs/workbench/test/common/editor/untitledTextEditor.test.ts
...s/workbench/test/common/editor/untitledTextEditor.test.ts
+4
-4
未找到文件。
src/vs/workbench/browser/parts/editor/editorActions.ts
浏览文件 @
5fd42b76
...
...
@@ -543,13 +543,13 @@ export class RevertAndCloseEditorAction extends Action {
// first try a normal revert where the contents of the editor are restored
try
{
await
editor
.
revert
();
await
editor
.
revert
(
group
.
id
);
}
catch
(
error
)
{
// if that fails, since we are about to close the editor, we accept that
// the editor cannot be reverted and instead do a soft revert that just
// enables us to close the editor. With this, a user can always close a
// dirty editor even when reverting fails.
await
editor
.
revert
({
soft
:
true
});
await
editor
.
revert
(
group
.
id
,
{
soft
:
true
});
}
group
.
closeEditor
(
editor
);
...
...
src/vs/workbench/browser/parts/editor/editorGroupView.ts
浏览文件 @
5fd42b76
...
...
@@ -1330,7 +1330,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
// Otherwise, handle accordingly
switch
(
res
)
{
case
ConfirmResult
.
SAVE
:
const
result
=
await
editor
.
save
(
this
.
_group
.
id
,
{
reason
:
SaveReason
.
EXPLICIT
,
context
:
SaveContext
.
EDITOR_CLOSE
});
const
result
=
await
editor
.
save
(
this
.
id
,
{
reason
:
SaveReason
.
EXPLICIT
,
context
:
SaveContext
.
EDITOR_CLOSE
});
return
!
result
;
case
ConfirmResult
.
DONT_SAVE
:
...
...
@@ -1338,7 +1338,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
try
{
// first try a normal revert where the contents of the editor are restored
const
result
=
await
editor
.
revert
();
const
result
=
await
editor
.
revert
(
this
.
id
);
return
!
result
;
}
catch
(
error
)
{
...
...
@@ -1346,7 +1346,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
// the editor cannot be reverted and instead do a soft revert that just
// enables us to close the editor. With this, a user can always close a
// dirty editor even when reverting fails.
const
result
=
await
editor
.
revert
({
soft
:
true
});
const
result
=
await
editor
.
revert
(
this
.
id
,
{
soft
:
true
});
return
!
result
;
}
...
...
src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
浏览文件 @
5fd42b76
...
...
@@ -16,7 +16,7 @@ import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/co
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
DisposableStore
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
EditorInput
,
toResource
,
Verbosity
,
SideBySideEditor
}
from
'
vs/workbench/common/editor
'
;
import
{
toResource
,
Verbosity
,
SideBySideEditor
}
from
'
vs/workbench/common/editor
'
;
import
{
IWorkbenchEnvironmentService
}
from
'
vs/workbench/services/environment/common/environmentService
'
;
import
{
IWorkspaceContextService
,
WorkbenchState
,
IWorkspaceFolder
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IThemeService
,
registerThemingParticipant
,
ITheme
,
ICssStyleCollector
}
from
'
vs/platform/theme/common/themeService
'
;
...
...
@@ -195,7 +195,7 @@ export class TitlebarPart extends Part implements ITitleService {
// Apply listener for dirty and label changes
const
activeEditor
=
this
.
editorService
.
activeEditor
;
if
(
activeEditor
instanceof
EditorInput
)
{
if
(
activeEditor
)
{
this
.
activeEditorListeners
.
add
(
activeEditor
.
onDidChangeDirty
(()
=>
this
.
titleUpdater
.
schedule
()));
this
.
activeEditorListeners
.
add
(
activeEditor
.
onDidChangeLabel
(()
=>
this
.
titleUpdater
.
schedule
()));
}
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
5fd42b76
...
...
@@ -362,6 +362,16 @@ export interface IEditorInput extends IDisposable {
*/
readonly
onDispose
:
Event
<
void
>
;
/**
* Triggered when this input changes its dirty state.
*/
readonly
onDidChangeDirty
:
Event
<
void
>
;
/**
* Triggered when this input changes its label
*/
readonly
onDidChangeLabel
:
Event
<
void
>
;
/**
* Returns the associated resource of this input.
*/
...
...
@@ -416,9 +426,9 @@ export interface IEditorInput extends IDisposable {
isSaving
():
boolean
;
/**
* Saves the editor. The provided groupId helps
*
implementors to e.g. preserve view state of the editor
*
and re-open it
in the correct group after saving.
* Saves the editor. The provided groupId helps
implementors
*
to e.g. preserve view state of the editor and re-open it
* in the correct group after saving.
*/
save
(
groupId
:
GroupIdentifier
,
options
?:
ISaveOptions
):
Promise
<
boolean
>
;
...
...
@@ -430,9 +440,9 @@ export interface IEditorInput extends IDisposable {
saveAs
(
groupId
:
GroupIdentifier
,
options
?:
ISaveOptions
):
Promise
<
boolean
>
;
/**
* Reverts this input.
* Reverts this input
from the provided group
.
*/
revert
(
options
?:
IRevertOptions
):
Promise
<
boolean
>
;
revert
(
group
:
GroupIdentifier
,
options
?:
IRevertOptions
):
Promise
<
boolean
>
;
/**
* Returns if the other object matches this input.
...
...
@@ -532,7 +542,7 @@ export abstract class EditorInput extends Disposable implements IEditorInput {
return
true
;
}
async
revert
(
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
async
revert
(
group
:
GroupIdentifier
,
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
return
true
;
}
...
...
@@ -614,6 +624,10 @@ export abstract class TextEditorInput extends EditorInput {
return
true
;
}
revert
(
group
:
GroupIdentifier
,
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
return
this
.
textFileService
.
revert
(
this
.
resource
,
options
);
}
}
export
const
enum
EncodingMode
{
...
...
@@ -743,8 +757,8 @@ export class SideBySideEditorInput extends EditorInput {
return
this
.
master
.
saveAs
(
groupId
,
options
);
}
revert
(
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
return
this
.
master
.
revert
(
options
);
revert
(
group
:
GroupIdentifier
,
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
return
this
.
master
.
revert
(
group
,
options
);
}
getTelemetryDescriptor
():
{
[
key
:
string
]:
unknown
}
{
...
...
src/vs/workbench/common/editor/untitledTextEditorInput.ts
浏览文件 @
5fd42b76
...
...
@@ -193,7 +193,7 @@ export class UntitledTextEditorInput extends TextEditorInput implements IEncodin
return
this
.
doSaveAs
(
group
,
options
,
()
=>
this
.
textFileService
.
saveAs
(
this
.
resource
,
undefined
,
options
),
true
/* replace editor across all groups */
);
}
async
revert
(
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
async
revert
(
group
:
GroupIdentifier
,
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
if
(
this
.
cachedModel
)
{
this
.
cachedModel
.
revert
();
}
...
...
src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts
浏览文件 @
5fd42b76
...
...
@@ -149,7 +149,7 @@ export class CustomFileEditorInput extends LazilyResolvedWebviewEditorInput {
return
true
;
}
public
revert
(
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
public
revert
(
group
:
GroupIdentifier
,
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
return
this
.
_model
?
this
.
_model
.
revert
(
options
)
:
Promise
.
resolve
(
false
);
}
...
...
src/vs/workbench/contrib/files/common/editors/fileEditorInput.ts
浏览文件 @
5fd42b76
...
...
@@ -7,7 +7,7 @@ import { localize } from 'vs/nls';
import
{
createMemoizer
}
from
'
vs/base/common/decorators
'
;
import
{
dirname
}
from
'
vs/base/common/resources
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
EncodingMode
,
IFileEditorInput
,
ITextEditorModel
,
Verbosity
,
TextEditorInput
,
IRevertOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
EncodingMode
,
IFileEditorInput
,
ITextEditorModel
,
Verbosity
,
TextEditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
TextFileEditorModel
}
from
'
vs/workbench/services/textfile/common/textFileEditorModel
'
;
import
{
BinaryEditorModel
}
from
'
vs/workbench/common/editor/binaryEditorModel
'
;
import
{
FileOperationError
,
FileOperationResult
,
IFileService
,
FileSystemProviderCapabilities
}
from
'
vs/platform/files/common/files
'
;
...
...
@@ -262,10 +262,6 @@ export class FileEditorInput extends TextEditorInput implements IFileEditorInput
return
false
;
}
revert
(
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
return
this
.
textFileService
.
revert
(
this
.
resource
,
options
);
}
getPreferredEditorId
(
candidates
:
string
[]):
string
{
return
this
.
forceOpenAs
===
ForceOpenAs
.
Binary
?
BINARY_FILE_EDITOR_ID
:
TEXT_FILE_EDITOR_ID
;
}
...
...
src/vs/workbench/contrib/files/test/browser/fileEditorInput.test.ts
浏览文件 @
5fd42b76
...
...
@@ -152,7 +152,7 @@ suite('Files - FileEditorInput', () => {
resolved
.
textEditorModel
!
.
setValue
(
'
changed
'
);
assert
.
ok
(
input
.
isDirty
());
assert
.
ok
(
await
input
.
revert
());
assert
.
ok
(
await
input
.
revert
(
0
));
assert
.
ok
(
!
input
.
isDirty
());
input
.
dispose
();
...
...
src/vs/workbench/contrib/search/browser/searchEditorInput.ts
浏览文件 @
5fd42b76
...
...
@@ -79,7 +79,7 @@ export class SearchEditorInput extends EditorInput {
isDirty
:
()
=>
this
.
isDirty
(),
backup
:
()
=>
this
.
backup
(),
save
:
(
options
)
=>
this
.
save
(
0
,
options
),
revert
:
()
=>
this
.
revert
(),
revert
:
()
=>
this
.
revert
(
0
),
};
this
.
workingCopyService
.
registerWorkingCopy
(
workingCopyAdapter
);
...
...
@@ -181,9 +181,9 @@ export class SearchEditorInput extends EditorInput {
return
false
;
}
async
revert
(
options
?:
IRevertOptions
)
{
async
revert
(
group
:
GroupIdentifier
,
options
?:
IRevertOptions
)
{
// TODO: this should actually revert the contents. But it needs to set dirty false.
super
.
revert
(
options
);
super
.
revert
(
group
,
options
);
this
.
setDirty
(
false
);
return
true
;
}
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
5fd42b76
...
...
@@ -737,7 +737,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
// Use revert as a hint to pin the editor
this
.
editorGroupService
.
getGroup
(
groupId
)?.
pinEditor
(
editor
);
return
editor
.
revert
(
options
);
return
editor
.
revert
(
groupId
,
options
);
}));
return
result
.
every
(
success
=>
!!
success
);
...
...
src/vs/workbench/services/editor/test/browser/editorService.test.ts
浏览文件 @
5fd42b76
...
...
@@ -80,7 +80,7 @@ class TestEditorInput extends EditorInput implements IFileEditorInput {
this
.
gotSavedAs
=
true
;
return
true
;
}
async
revert
(
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
async
revert
(
group
:
GroupIdentifier
,
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
this
.
gotReverted
=
true
;
this
.
gotSaved
=
false
;
this
.
gotSavedAs
=
false
;
...
...
src/vs/workbench/services/textfile/browser/textFileService.ts
浏览文件 @
5fd42b76
...
...
@@ -579,7 +579,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
if
(
resource
.
scheme
===
Schemas
.
untitled
)
{
const
model
=
this
.
untitled
.
get
(
resource
);
if
(
model
)
{
return
model
.
revert
(
options
);
return
model
.
revert
(
0
,
options
);
}
return
false
;
...
...
src/vs/workbench/test/common/editor/untitledTextEditor.test.ts
浏览文件 @
5fd42b76
...
...
@@ -62,7 +62,7 @@ suite('Workbench untitled text editors', () => {
assert
.
equal
(
service
.
get
(
input2
.
getResource
()),
input2
);
// revert()
input1
.
revert
();
input1
.
revert
(
0
);
assert
.
ok
(
input1
.
isDisposed
());
assert
.
ok
(
!
service
.
get
(
input1
.
getResource
()));
...
...
@@ -82,8 +82,8 @@ suite('Workbench untitled text editors', () => {
assert
.
ok
(
workingCopyService
.
isDirty
(
input2
.
getResource
()));
assert
.
equal
(
workingCopyService
.
dirtyCount
,
1
);
input1
.
revert
();
input2
.
revert
();
input1
.
revert
(
0
);
input2
.
revert
(
0
);
assert
.
ok
(
!
service
.
get
(
input1
.
getResource
()));
assert
.
ok
(
!
service
.
get
(
input2
.
getResource
()));
assert
.
ok
(
!
input2
.
isDirty
());
...
...
@@ -92,7 +92,7 @@ suite('Workbench untitled text editors', () => {
assert
.
ok
(
!
workingCopyService
.
isDirty
(
input2
.
getResource
()));
assert
.
equal
(
workingCopyService
.
dirtyCount
,
0
);
assert
.
ok
(
input1
.
revert
());
assert
.
ok
(
input1
.
revert
(
0
));
assert
.
ok
(
input1
.
isDisposed
());
assert
.
ok
(
!
service
.
exists
(
input1
.
getResource
()));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录