Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
5e92eb1e
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
5e92eb1e
编写于
9月 06, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Empty untitled file should not show up as dirty (fixes #11554)
上级
b0819957
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
10 deletion
+23
-10
src/vs/workbench/common/editor/untitledEditorInput.ts
src/vs/workbench/common/editor/untitledEditorInput.ts
+5
-5
src/vs/workbench/common/editor/untitledEditorModel.ts
src/vs/workbench/common/editor/untitledEditorModel.ts
+16
-3
src/vs/workbench/services/untitled/common/untitledEditorService.ts
...rkbench/services/untitled/common/untitledEditorService.ts
+2
-2
未找到文件。
src/vs/workbench/common/editor/untitledEditorInput.ts
浏览文件 @
5e92eb1e
...
...
@@ -92,7 +92,7 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
public
suggestFileName
():
string
{
if
(
!
this
.
hasAssociatedFilePath
)
{
le
t
mime
=
this
.
getMime
();
cons
t
mime
=
this
.
getMime
();
if
(
mime
&&
mime
!==
MIME_TEXT
/* do not suggest when the mime type is simple plain text */
)
{
return
suggestFilename
(
mime
,
this
.
getName
());
}
...
...
@@ -131,7 +131,7 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
}
// Otherwise Create Model and load
le
t
model
=
this
.
createModel
();
cons
t
model
=
this
.
createModel
();
return
model
.
load
().
then
((
resolvedModel
:
UntitledEditorModel
)
=>
{
this
.
cachedModel
=
resolvedModel
;
...
...
@@ -140,10 +140,10 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
}
private
createModel
():
UntitledEditorModel
{
le
t
content
=
''
;
cons
t
content
=
''
;
let
mime
=
this
.
modeId
;
if
(
!
mime
&&
this
.
hasAssociatedFilePath
)
{
le
t
mimeFromPath
=
guessMimeTypes
(
this
.
resource
.
fsPath
)[
0
];
cons
t
mimeFromPath
=
guessMimeTypes
(
this
.
resource
.
fsPath
)[
0
];
if
(
!
isUnspecific
(
mimeFromPath
))
{
mime
=
mimeFromPath
;
// take most specific mime type if file path is associated and mime is specific
}
...
...
@@ -163,7 +163,7 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
}
if
(
otherInput
instanceof
UntitledEditorInput
)
{
le
t
otherUntitledEditorInput
=
<
UntitledEditorInput
>
otherInput
;
cons
t
otherUntitledEditorInput
=
<
UntitledEditorInput
>
otherInput
;
// Otherwise compare by properties
return
otherUntitledEditorInput
.
resource
.
toString
()
===
this
.
resource
.
toString
();
...
...
src/vs/workbench/common/editor/untitledEditorModel.ts
浏览文件 @
5e92eb1e
...
...
@@ -9,6 +9,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
import
{
EditorModel
,
IEncodingSupport
}
from
'
vs/workbench/common/editor
'
;
import
{
StringEditorModel
}
from
'
vs/workbench/common/editor/stringEditorModel
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
IModelContentChangedEvent2
}
from
'
vs/editor/common/editorCommon
'
;
import
{
EventType
,
EndOfLinePreference
}
from
'
vs/editor/common/editorCommon
'
;
import
{
EventType
as
WorkbenchEventType
,
ResourceEvent
}
from
'
vs/workbench/common/events
'
;
import
{
IFilesConfiguration
}
from
'
vs/platform/files/common/files
'
;
...
...
@@ -30,6 +31,8 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
private
configuredEncoding
:
string
;
private
preferredEncoding
:
string
;
private
hasAssociatedFilePath
:
boolean
;
constructor
(
value
:
string
,
mime
:
string
,
...
...
@@ -42,6 +45,7 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
)
{
super
(
value
,
mime
,
resource
,
modeService
,
modelService
);
this
.
hasAssociatedFilePath
=
hasAssociatedFilePath
;
this
.
dirty
=
hasAssociatedFilePath
;
// untitled associated to file path are dirty right away
this
.
_onDidChangeDirty
=
new
Emitter
<
void
>
();
...
...
@@ -92,7 +96,7 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
}
public
setEncoding
(
encoding
:
string
):
void
{
le
t
oldEncoding
=
this
.
getEncoding
();
cons
t
oldEncoding
=
this
.
getEncoding
();
this
.
preferredEncoding
=
encoding
;
// Emit if it changed
...
...
@@ -119,7 +123,7 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
this
.
configuredEncoding
=
configuration
&&
configuration
.
files
&&
configuration
.
files
.
encoding
;
// Listen to content changes
this
.
textModelChangeListener
=
this
.
textEditorModel
.
onDidChangeContent
(
()
=>
this
.
onModelContentChanged
(
));
this
.
textModelChangeListener
=
this
.
textEditorModel
.
onDidChangeContent
(
e
=>
this
.
onModelContentChanged
(
e
));
// Emit initial dirty event if we are
if
(
this
.
dirty
)
{
...
...
@@ -132,11 +136,20 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
});
}
private
onModelContentChanged
():
void
{
private
onModelContentChanged
(
e
:
IModelContentChangedEvent2
):
void
{
// turn dirty if we were not
if
(
!
this
.
dirty
)
{
this
.
dirty
=
true
;
this
.
_onDidChangeDirty
.
fire
();
}
// mark the untitled editor as non-dirty once its content becomes empty and we do
// not have an associated path set
else
if
(
!
this
.
hasAssociatedFilePath
&&
!
e
.
text
&&
this
.
textEditorModel
.
getValueLength
()
===
0
)
{
this
.
dirty
=
false
;
this
.
_onDidChangeDirty
.
fire
();
}
}
public
dispose
():
void
{
...
...
src/vs/workbench/services/untitled/common/untitledEditorService.ts
浏览文件 @
5e92eb1e
...
...
@@ -109,7 +109,7 @@ export class UntitledEditorService implements IUntitledEditorService {
}
public
isDirty
(
resource
:
URI
):
boolean
{
le
t
input
=
this
.
get
(
resource
);
cons
t
input
=
this
.
get
(
resource
);
return
input
&&
input
.
isDirty
();
}
...
...
@@ -152,7 +152,7 @@ export class UntitledEditorService implements IUntitledEditorService {
}
while
(
Object
.
keys
(
UntitledEditorService
.
CACHE
).
indexOf
(
resource
.
toString
())
>=
0
);
}
le
t
input
=
this
.
instantiationService
.
createInstance
(
UntitledEditorInput
,
resource
,
hasAssociatedFilePath
,
modeId
);
cons
t
input
=
this
.
instantiationService
.
createInstance
(
UntitledEditorInput
,
resource
,
hasAssociatedFilePath
,
modeId
);
const
listener
=
input
.
onDidChangeDirty
(()
=>
{
this
.
_onDidChangeDirty
.
fire
(
new
UntitledEditorEvent
(
resource
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录