Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e4f0dec7
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,发现更多精彩内容 >>
提交
e4f0dec7
编写于
10月 13, 2016
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove usage of fs in common/ layer
上级
701fe8cf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
16 deletion
+16
-16
src/vs/workbench/common/editor/untitledEditorInput.ts
src/vs/workbench/common/editor/untitledEditorInput.ts
+15
-15
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+1
-1
未找到文件。
src/vs/workbench/common/editor/untitledEditorInput.ts
浏览文件 @
e4f0dec7
...
@@ -19,9 +19,6 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
...
@@ -19,9 +19,6 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
// TODO: This file cannot depend on native node modules
import
fs
=
require
(
'
fs
'
);
/**
/**
* An editor input to be used for untitled text buffers.
* An editor input to be used for untitled text buffers.
*/
*/
...
@@ -50,7 +47,6 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
...
@@ -50,7 +47,6 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
@
ITextFileService
private
textFileService
:
ITextFileService
@
ITextFileService
private
textFileService
:
ITextFileService
)
{
)
{
super
();
super
();
console
.
log
(
'
UntitledEditorInput constructor
'
,
resource
,
hasAssociatedFilePath
,
modeId
);
this
.
resource
=
resource
;
this
.
resource
=
resource
;
this
.
hasAssociatedFilePath
=
hasAssociatedFilePath
;
this
.
hasAssociatedFilePath
=
hasAssociatedFilePath
;
this
.
modeId
=
modeId
;
this
.
modeId
=
modeId
;
...
@@ -138,21 +134,25 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
...
@@ -138,21 +134,25 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
return
TPromise
.
as
(
this
.
cachedModel
);
return
TPromise
.
as
(
this
.
cachedModel
);
}
}
// Otherwise Create Model and load
// Otherwise Create Model and load, restoring from backup if necessary
const
model
=
this
.
createModel
();
let
restorePromise
:
TPromise
<
string
>
;
return
model
.
load
().
then
((
resolvedModel
:
UntitledEditorModel
)
=>
{
if
(
this
.
restoreResource
)
{
this
.
cachedModel
=
resolvedModel
;
restorePromise
=
this
.
textFileService
.
resolveTextContent
(
this
.
restoreResource
).
then
(
rawTextContent
=>
rawTextContent
.
value
.
lines
.
join
(
'
\n
'
));
}
else
{
restorePromise
=
TPromise
.
as
(
''
);
}
return
restorePromise
.
then
(
content
=>
{
const
model
=
this
.
createModel
(
content
);
return
model
.
load
().
then
((
resolvedModel
:
UntitledEditorModel
)
=>
{
this
.
cachedModel
=
resolvedModel
;
return
this
.
cachedModel
;
return
this
.
cachedModel
;
});
});
});
}
}
private
createModel
():
UntitledEditorModel
{
private
createModel
(
content
:
string
):
UntitledEditorModel
{
let
content
=
''
;
if
(
this
.
restoreResource
)
{
// TODO: This loading should probably go through fileService, fs cannot be a dependency in common/
content
=
fs
.
readFileSync
(
this
.
restoreResource
.
fsPath
,
'
utf8
'
);
}
const
model
=
this
.
instantiationService
.
createInstance
(
UntitledEditorModel
,
content
,
this
.
modeId
,
this
.
resource
,
this
.
hasAssociatedFilePath
);
const
model
=
this
.
instantiationService
.
createInstance
(
UntitledEditorModel
,
content
,
this
.
modeId
,
this
.
resource
,
this
.
hasAssociatedFilePath
);
// re-emit some events from the model
// re-emit some events from the model
...
...
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
e4f0dec7
...
@@ -177,7 +177,7 @@ export class Workbench implements IPartService {
...
@@ -177,7 +177,7 @@ export class Workbench implements IPartService {
return
{
resource
:
Uri
.
file
(
filePath
),
options
:
{
pinned
:
true
}
};
return
{
resource
:
Uri
.
file
(
filePath
),
options
:
{
pinned
:
true
}
};
});
});
options
.
untitledFilesToRestore
=
this
.
backupService
.
getBackupUntitledFiles
(
workspace
.
resource
.
fsPath
).
map
(
untitledFilePath
=>
{
options
.
untitledFilesToRestore
=
this
.
backupService
.
getBackupUntitledFiles
(
workspace
.
resource
.
fsPath
).
map
(
untitledFilePath
=>
{
return
{
resource
:
Uri
.
f
rom
({
path
:
untitledFilePath
,
scheme
:
'
untitled
'
}
),
options
:
{
pinned
:
true
}
};
return
{
resource
:
Uri
.
f
ile
(
untitledFilePath
),
options
:
{
pinned
:
true
}
};
});
});
this
.
hasFilesToCreateOpenOrDiff
=
this
.
hasFilesToCreateOpenOrDiff
=
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录