Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
0256f00d
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
Vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0256f00d
编写于
6月 04, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
improve revert logic for untitled
上级
385412e8
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
50 addition
and
31 deletion
+50
-31
src/vs/workbench/browser/parts/editor/stringEditor.ts
src/vs/workbench/browser/parts/editor/stringEditor.ts
+2
-2
src/vs/workbench/common/editor/untitledEditorInput.ts
src/vs/workbench/common/editor/untitledEditorInput.ts
+7
-5
src/vs/workbench/common/editor/untitledEditorModel.ts
src/vs/workbench/common/editor/untitledEditorModel.ts
+6
-4
src/vs/workbench/common/events.ts
src/vs/workbench/common/events.ts
+2
-2
src/vs/workbench/parts/files/browser/fileActions.ts
src/vs/workbench/parts/files/browser/fileActions.ts
+1
-1
src/vs/workbench/parts/files/browser/fileTracker.ts
src/vs/workbench/parts/files/browser/fileTracker.ts
+2
-2
src/vs/workbench/parts/files/electron-browser/electronFileTracker.ts
...bench/parts/files/electron-browser/electronFileTracker.ts
+2
-2
src/vs/workbench/parts/files/electron-browser/textFileServices.ts
...orkbench/parts/files/electron-browser/textFileServices.ts
+2
-11
src/vs/workbench/parts/search/browser/searchViewlet.ts
src/vs/workbench/parts/search/browser/searchViewlet.ts
+2
-2
src/vs/workbench/services/untitled/common/untitledEditorService.ts
...rkbench/services/untitled/common/untitledEditorService.ts
+20
-0
src/vs/workbench/test/common/servicesTestUtils.ts
src/vs/workbench/test/common/servicesTestUtils.ts
+4
-0
未找到文件。
src/vs/workbench/browser/parts/editor/stringEditor.ts
浏览文件 @
0256f00d
...
...
@@ -51,10 +51,10 @@ export class StringEditor extends BaseTextEditor {
this
.
mapResourceToEditorViewState
=
Object
.
create
(
null
);
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
EventType
.
UNTITLED_FILE_
DELETED
,
(
e
:
UntitledEditorEvent
)
=>
this
.
onUntitledDelet
edEvent
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
EventType
.
UNTITLED_FILE_
SAVED
,
(
e
:
UntitledEditorEvent
)
=>
this
.
onUntitledSav
edEvent
(
e
)));
}
private
onUntitled
Delet
edEvent
(
e
:
UntitledEditorEvent
):
void
{
private
onUntitled
Sav
edEvent
(
e
:
UntitledEditorEvent
):
void
{
delete
this
.
mapResourceToEditorViewState
[
e
.
resource
.
toString
()];
}
...
...
src/vs/workbench/common/editor/untitledEditorInput.ts
浏览文件 @
0256f00d
...
...
@@ -58,7 +58,7 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
}
private
registerListeners
():
void
{
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_
DELET
ED
,
(
e
:
UntitledEditorEvent
)
=>
this
.
onDirtyStateChange
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_
SAV
ED
,
(
e
:
UntitledEditorEvent
)
=>
this
.
onDirtyStateChange
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_DIRTY
,
(
e
:
UntitledEditorEvent
)
=>
this
.
onDirtyStateChange
(
e
)));
}
...
...
@@ -97,7 +97,9 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
}
public
revert
():
TPromise
<
boolean
>
{
return
this
.
textFileService
.
revert
(
this
.
resource
);
this
.
cachedModel
.
revert
();
return
TPromise
.
as
(
true
);
}
public
suggestFileName
():
string
{
...
...
@@ -179,15 +181,15 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
public
dispose
():
void
{
// Listeners
dispose
(
this
.
toUnbind
);
// Model
if
(
this
.
cachedModel
)
{
this
.
cachedModel
.
dispose
();
this
.
cachedModel
=
null
;
}
// Listeners
dispose
(
this
.
toUnbind
);
super
.
dispose
();
}
}
\ No newline at end of file
src/vs/workbench/common/editor/untitledEditorModel.ts
浏览文件 @
0256f00d
...
...
@@ -86,6 +86,12 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
return
this
.
dirty
;
}
public
revert
():
void
{
this
.
dirty
=
false
;
this
.
eventService
.
emit
(
WorkbenchEventType
.
UNTITLED_FILE_SAVED
,
new
UntitledEditorEvent
(
this
.
resource
));
}
public
load
():
TPromise
<
EditorModel
>
{
return
super
.
load
().
then
((
model
)
=>
{
const
configuration
=
this
.
configurationService
.
getConfiguration
<
IFilesConfiguration
>
();
...
...
@@ -117,8 +123,6 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
public
dispose
():
void
{
super
.
dispose
();
this
.
dirty
=
false
;
// we can no longer be dirty
if
(
this
.
textModelChangeListener
)
{
this
.
textModelChangeListener
.
dispose
();
this
.
textModelChangeListener
=
null
;
...
...
@@ -128,7 +132,5 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
this
.
configurationChangeListener
.
dispose
();
this
.
configurationChangeListener
=
null
;
}
this
.
eventService
.
emit
(
WorkbenchEventType
.
UNTITLED_FILE_DELETED
,
new
UntitledEditorEvent
(
this
.
resource
));
}
}
\ No newline at end of file
src/vs/workbench/common/events.ts
浏览文件 @
0256f00d
...
...
@@ -33,9 +33,9 @@ export class EventType {
static
UNTITLED_FILE_DIRTY
=
'
untitledFileDirty
'
;
/**
* Event type for when an untitled file is
delet
ed.
* Event type for when an untitled file is
sav
ed.
*/
static
UNTITLED_FILE_
DELETED
=
'
untitledFileDelet
ed
'
;
static
UNTITLED_FILE_
SAVED
=
'
untitledFileSav
ed
'
;
/**
* Event type for when a resources encoding changes.
...
...
src/vs/workbench/parts/files/browser/fileActions.ts
浏览文件 @
0256f00d
...
...
@@ -1535,7 +1535,7 @@ export abstract class BaseSaveAllAction extends BaseActionWithErrorReporting {
if
(
this
.
includeUntitled
())
{
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_DIRTY
,
()
=>
this
.
updateEnablement
(
true
)));
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_
DELET
ED
,
()
=>
this
.
updateEnablement
(
false
)));
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_
SAV
ED
,
()
=>
this
.
updateEnablement
(
false
)));
}
}
...
...
src/vs/workbench/parts/files/browser/fileTracker.ts
浏览文件 @
0256f00d
...
...
@@ -65,7 +65,7 @@ export class FileTracker implements IWorkbenchContribution {
// Update editors and inputs from local changes and saves
this
.
toUnbind
.
push
(
this
.
editorGroupService
.
onEditorsChanged
(()
=>
this
.
onEditorsChanged
()));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_
DELETED
,
(
e
:
UntitledEditorEvent
)
=>
this
.
onUntitledEditorDelet
ed
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_
SAVED
,
(
e
:
UntitledEditorEvent
)
=>
this
.
onUntitledEditorSav
ed
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_DIRTY
,
(
e
:
UntitledEditorEvent
)
=>
this
.
onUntitledEditorDirty
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
FileEventType
.
FILE_DIRTY
,
(
e
:
TextFileChangeEvent
)
=>
this
.
onTextFileDirty
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
FileEventType
.
FILE_SAVE_ERROR
,
(
e
:
TextFileChangeEvent
)
=>
this
.
onTextFileSaveError
(
e
)));
...
...
@@ -107,7 +107,7 @@ export class FileTracker implements IWorkbenchContribution {
this
.
updateActivityBadge
();
}
private
onUntitledEditor
Delet
ed
(
e
:
UntitledEditorEvent
):
void
{
private
onUntitledEditor
Sav
ed
(
e
:
UntitledEditorEvent
):
void
{
if
(
this
.
lastDirtyCount
>
0
)
{
this
.
updateActivityBadge
();
}
...
...
src/vs/workbench/parts/files/electron-browser/electronFileTracker.ts
浏览文件 @
0256f00d
...
...
@@ -77,7 +77,7 @@ export class FileTracker implements IWorkbenchContribution {
private
registerListeners
():
void
{
// Local text file changes
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_
DELETED
,
()
=>
this
.
onUntitledDelet
edEvent
()));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_
SAVED
,
()
=>
this
.
onUntitledSav
edEvent
()));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_DIRTY
,
()
=>
this
.
onUntitledDirtyEvent
()));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
FileEventType
.
FILE_DIRTY
,
(
e
:
TextFileChangeEvent
)
=>
this
.
onTextFileDirty
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
FileEventType
.
FILE_SAVED
,
(
e
:
TextFileChangeEvent
)
=>
this
.
onTextFileSaved
(
e
)));
...
...
@@ -199,7 +199,7 @@ export class FileTracker implements IWorkbenchContribution {
}
}
private
onUntitled
Delet
edEvent
():
void
{
private
onUntitled
Sav
edEvent
():
void
{
if
(
this
.
isDocumentedEdited
)
{
this
.
updateDocumentEdited
();
}
...
...
src/vs/workbench/parts/files/electron-browser/textFileServices.ts
浏览文件 @
0256f00d
...
...
@@ -117,17 +117,8 @@ export class TextFileService extends AbstractTextFileService {
return
super
.
revertAll
(
resources
,
force
).
then
(
r
=>
{
// Revert untitled
let
untitledInputs
=
this
.
untitledEditorService
.
getAll
(
resources
);
untitledInputs
.
forEach
(
input
=>
{
if
(
input
)
{
input
.
dispose
();
r
.
results
.
push
({
source
:
input
.
getResource
(),
success
:
true
});
}
});
const
reverted
=
this
.
untitledEditorService
.
revertAll
(
resources
);
reverted
.
forEach
(
res
=>
r
.
results
.
push
({
source
:
res
,
success
:
true
}));
return
r
;
});
...
...
src/vs/workbench/parts/search/browser/searchViewlet.ts
浏览文件 @
0256f00d
...
...
@@ -692,7 +692,7 @@ export class SearchViewlet extends Viewlet {
this
.
viewletSettings
=
this
.
getMemento
(
storageService
,
Scope
.
WORKSPACE
);
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
FileEventType
.
FILE_CHANGES
,
(
e
)
=>
this
.
onFilesChanged
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_
DELETED
,
(
e
)
=>
this
.
onUntitledFileDelet
ed
(
e
)));
this
.
toUnbind
.
push
(
this
.
eventService
.
addListener2
(
WorkbenchEventType
.
UNTITLED_FILE_
SAVED
,
(
e
)
=>
this
.
onUntitledFileSav
ed
(
e
)));
this
.
toUnbind
.
push
(
this
.
configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
onConfigurationUpdated
(
e
.
config
)));
}
...
...
@@ -1456,7 +1456,7 @@ export class SearchViewlet extends Viewlet {
},
sideBySide
);
}
private
onUntitledFile
Delet
ed
(
e
:
UntitledEditorEvent
):
void
{
private
onUntitledFile
Sav
ed
(
e
:
UntitledEditorEvent
):
void
{
if
(
!
this
.
viewModel
)
{
return
;
}
...
...
src/vs/workbench/services/untitled/common/untitledEditorService.ts
浏览文件 @
0256f00d
...
...
@@ -36,6 +36,11 @@ export interface IUntitledEditorService {
*/
isDirty
(
resource
:
URI
):
boolean
;
/**
* Reverts the untitled resources if found.
*/
revertAll
(
resources
?:
URI
[]):
URI
[];
/**
* Creates a new untitled input with the optional resource URI or returns an existing one
* if the provided resource exists already as untitled input.
...
...
@@ -72,6 +77,21 @@ export class UntitledEditorService implements IUntitledEditorService {
return
Object
.
keys
(
UntitledEditorService
.
CACHE
).
map
((
key
)
=>
UntitledEditorService
.
CACHE
[
key
]);
}
public
revertAll
(
resources
?:
URI
[],
force
?:
boolean
):
URI
[]
{
const
reverted
:
URI
[]
=
[];
const
untitledInputs
=
this
.
getAll
(
resources
);
untitledInputs
.
forEach
(
input
=>
{
if
(
input
)
{
input
.
revert
();
reverted
.
push
(
input
.
getResource
());
}
});
return
reverted
;
}
public
isDirty
(
resource
:
URI
):
boolean
{
let
input
=
this
.
get
(
resource
);
...
...
src/vs/workbench/test/common/servicesTestUtils.ts
浏览文件 @
0256f00d
...
...
@@ -295,6 +295,10 @@ export class TestUntitledEditorService implements IUntitledEditorService {
return
[];
}
public
revertAll
(
resources
?:
URI
[]):
URI
[]
{
return
[];
}
public
isDirty
()
{
return
false
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录