Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
17680ec6
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,发现更多精彩内容 >>
提交
17680ec6
编写于
12月 04, 2015
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ITextFileService.save() should trigger more UI updating (fixes #939)
上级
48375210
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
46 deletion
+35
-46
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+9
-1
src/vs/workbench/parts/files/browser/fileActions.ts
src/vs/workbench/parts/files/browser/fileActions.ts
+13
-30
src/vs/workbench/parts/files/electron-browser/textFileServices.ts
...orkbench/parts/files/electron-browser/textFileServices.ts
+13
-15
未找到文件。
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
17680ec6
...
...
@@ -209,7 +209,15 @@ export class EditorPart extends Part implements IEditorPart {
// Close editor when input provided and input gets disposed
if
(
input
)
{
this
.
visibleInputListeners
[
position
]
=
input
.
addListener
(
EventType
.
DISPOSE
,
()
=>
{
this
.
closeEditors
(
false
,
input
).
done
(
null
,
errors
.
onUnexpectedError
);
// To prevent race conditions, we call the close in a timeout because it can well be
// that an input is being disposed with the intent to replace it with some other input
// right after.
setTimeout
(()
=>
{
if
(
input
===
this
.
visibleInputs
[
position
])
{
this
.
closeEditors
(
false
,
input
).
done
(
null
,
errors
.
onUnexpectedError
);
}
},
0
);
});
}
...
...
src/vs/workbench/parts/files/browser/fileActions.ts
浏览文件 @
17680ec6
...
...
@@ -1527,9 +1527,8 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
encodingOfSource
=
textModel
&&
textModel
.
getEncoding
();
// text model can be null e.g. if this is a binary file!
}
let
savePromise
:
TPromise
<
URI
>
;
// Special case: an untitled file with associated path gets saved directly unless "saveAs" is true
let
savePromise
:
TPromise
<
URI
>
;
if
(
!
this
.
isSaveAs
()
&&
source
.
scheme
===
'
untitled
'
&&
this
.
untitledEditorService
.
hasAssociatedFilePath
(
source
))
{
savePromise
=
this
.
textFileService
.
save
(
source
).
then
((
result
)
=>
{
if
(
result
)
{
...
...
@@ -1550,9 +1549,6 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
return
;
}
// Add to working files
this
.
textFileService
.
getWorkingFilesModel
().
addEntry
(
target
);
// Reopen editors for the resource based on the positions
let
reopenPromise
=
Promise
.
as
(
null
);
if
(
target
.
toString
()
!==
source
.
toString
()
&&
positionsOfSource
.
length
)
{
...
...
@@ -1569,11 +1565,7 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
});
}
return
reopenPromise
.
then
(()
=>
{
// Revert source
this
.
textFileService
.
revert
(
source
);
});
return
reopenPromise
;
});
}
...
...
@@ -1653,16 +1645,17 @@ export abstract class BaseSaveAllAction extends BaseActionWithErrorReporting {
protected
doRun
():
TPromise
<
boolean
>
{
// Store mimes per untitled file to restore later
const
mapUntitledToProperties
:
{[
resource
:
string
]:
{
mime
:
string
;
encoding
:
string
;
}}
=
Object
.
create
(
null
);
this
.
textFileService
.
getDirty
()
.
filter
(
r
=>
r
.
scheme
===
'
untitled
'
)
// All untitled resources^
.
map
(
r
=>
this
.
untitledEditorService
.
get
(
r
))
// Mapped to their inputs
.
filter
(
i
=>
!!
i
)
// If possible :)
.
forEach
(
i
=>
mapUntitledToProperties
[
i
.
getResource
().
toString
()]
=
{
mime
:
i
.
getMime
(),
encoding
:
i
.
getEncoding
()
});
// Save all
return
this
.
textFileService
.
saveAll
(
this
.
includeUntitled
()).
then
((
result
)
=>
{
// add all targets to working files
result
.
results
.
forEach
((
res
)
=>
{
if
(
res
.
success
&&
res
.
target
)
{
this
.
textFileService
.
getWorkingFilesModel
().
addEntry
(
res
.
target
);
}
});
// all saved - now try to reopen saved untitled ones
if
(
this
.
includeUntitled
())
{
let
untitledResults
=
result
.
results
.
filter
((
res
)
=>
res
.
source
.
scheme
===
'
untitled
'
);
...
...
@@ -1674,12 +1667,12 @@ export abstract class BaseSaveAllAction extends BaseActionWithErrorReporting {
let
positions
=
findSaveAsPositions
(
this
.
editorService
,
res
.
source
);
let
mimeOfSource
:
string
;
let
selectedMime
=
this
.
untitledEditorService
.
get
(
res
.
source
).
getMime
()
;
let
selectedMime
=
mapUntitledToProperties
[
res
.
source
.
toString
()]
&&
mapUntitledToProperties
[
res
.
source
.
toString
()].
mime
;
if
(
!
isUnspecific
(
selectedMime
))
{
mimeOfSource
=
[
selectedMime
,
MIME_TEXT
].
join
(
'
,
'
);
}
let
encodingOfSource
:
string
=
this
.
untitledEditorService
.
get
(
res
.
source
).
getEncoding
()
;
let
encodingOfSource
:
string
=
mapUntitledToProperties
[
res
.
source
.
toString
()]
&&
mapUntitledToProperties
[
res
.
source
.
toString
()].
encoding
;
let
targetInput
=
this
.
instantiationService
.
createInstance
(
FileEditorInput
,
res
.
target
,
mimeOfSource
,
encodingOfSource
);
...
...
@@ -1708,17 +1701,7 @@ export abstract class BaseSaveAllAction extends BaseActionWithErrorReporting {
});
}
// After reopen, revert untitled ones
return
reopenPromise
.
then
(()
=>
{
return
Promise
.
join
(
untitledResults
.
map
((
res
)
=>
{
let
revertPromise
=
Promise
.
as
(
null
);
if
(
res
.
success
)
{
revertPromise
=
this
.
textFileService
.
revert
(
res
.
source
);
}
return
revertPromise
;
}));
});
return
reopenPromise
;
}
});
}
...
...
src/vs/workbench/parts/files/electron-browser/textFileServices.ts
浏览文件 @
17680ec6
...
...
@@ -70,17 +70,6 @@ export class TextFileService extends BrowserTextFileService {
// Save
if
(
confirm
===
ConfirmResult
.
SAVE
)
{
return
this
.
saveAll
(
true
/* includeUntitled */
).
then
((
result
)
=>
{
// Dispose saved untitled ones to not leave them around as dirty
result
.
results
.
forEach
((
res
)
=>
{
if
(
res
.
success
&&
res
.
source
.
scheme
===
'
untitled
'
)
{
let
input
=
this
.
untitledEditorService
.
get
(
res
.
source
);
if
(
input
)
{
input
.
dispose
();
}
}
});
if
(
result
.
results
.
some
((
r
)
=>
!
r
.
success
))
{
return
true
;
// veto if some saves failed
}
...
...
@@ -326,13 +315,22 @@ export class TextFileService extends BrowserTextFileService {
// We have a model: Use it (can be null e.g. if this file is binary and not a text file or was never opened before)
if
(
model
)
{
return
this
.
fileService
.
updateContent
(
target
,
model
.
getValue
(),
{
charset
:
model
.
getEncoding
()
}).
then
(()
=>
{
return
target
;
});
return
this
.
fileService
.
updateContent
(
target
,
model
.
getValue
(),
{
charset
:
model
.
getEncoding
()
});
}
// Otherwise we can only copy
return
this
.
fileService
.
copyFile
(
resource
,
target
).
then
(()
=>
target
);
return
this
.
fileService
.
copyFile
(
resource
,
target
);
}).
then
(()
=>
{
// Add target to working files because this is an operation that indicates activity
this
.
getWorkingFilesModel
().
addEntry
(
target
);
// Revert the source
return
this
.
revert
(
resource
).
then
(()
=>
{
// Done: return target
return
target
;
});
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录