Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c5e3c8f1
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,发现更多精彩内容 >>
提交
c5e3c8f1
编写于
6月 09, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Untitled: picked encoding is not restored after restart (fixes #28364)
上级
11c9c5bd
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
32 addition
and
35 deletion
+32
-35
src/vs/platform/editor/common/editor.ts
src/vs/platform/editor/common/editor.ts
+5
-0
src/vs/workbench/browser/parts/editor/editor.contribution.ts
src/vs/workbench/browser/parts/editor/editor.contribution.ts
+5
-2
src/vs/workbench/common/editor/untitledEditorInput.ts
src/vs/workbench/common/editor/untitledEditorInput.ts
+9
-11
src/vs/workbench/common/editor/untitledEditorModel.ts
src/vs/workbench/common/editor/untitledEditorModel.ts
+3
-8
src/vs/workbench/parts/files/common/editors/fileEditorInput.ts
...s/workbench/parts/files/common/editors/fileEditorInput.ts
+2
-7
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+1
-1
src/vs/workbench/services/untitled/common/untitledEditorService.ts
...rkbench/services/untitled/common/untitledEditorService.ts
+7
-6
未找到文件。
src/vs/platform/editor/common/editor.ts
浏览文件 @
c5e3c8f1
...
@@ -90,6 +90,11 @@ export interface IUntitledResourceInput extends IBaseResourceInput {
...
@@ -90,6 +90,11 @@ export interface IUntitledResourceInput extends IBaseResourceInput {
* Optional contents of the untitled resource.
* Optional contents of the untitled resource.
*/
*/
contents
?:
string
;
contents
?:
string
;
/**
* Optional encoding of the untitled resource.
*/
encoding
?:
string
;
}
}
export
interface
IResourceDiffInput
extends
IBaseResourceInput
{
export
interface
IResourceDiffInput
extends
IBaseResourceInput
{
...
...
src/vs/workbench/browser/parts/editor/editor.contribution.ts
浏览文件 @
c5e3c8f1
...
@@ -93,6 +93,7 @@ interface ISerializedUntitledEditorInput {
...
@@ -93,6 +93,7 @@ interface ISerializedUntitledEditorInput {
resource
:
string
;
resource
:
string
;
resourceJSON
:
any
;
resourceJSON
:
any
;
modeId
:
string
;
modeId
:
string
;
encoding
:
string
;
}
}
// Register Editor Input Factory
// Register Editor Input Factory
...
@@ -118,7 +119,8 @@ class UntitledEditorInputFactory implements IEditorInputFactory {
...
@@ -118,7 +119,8 @@ class UntitledEditorInputFactory implements IEditorInputFactory {
const
serialized
:
ISerializedUntitledEditorInput
=
{
const
serialized
:
ISerializedUntitledEditorInput
=
{
resource
:
resource
.
toString
(),
// Keep for backwards compatibility
resource
:
resource
.
toString
(),
// Keep for backwards compatibility
resourceJSON
:
resource
.
toJSON
(),
resourceJSON
:
resource
.
toJSON
(),
modeId
:
untitledEditorInput
.
getModeId
()
modeId
:
untitledEditorInput
.
getModeId
(),
encoding
:
untitledEditorInput
.
getEncoding
()
};
};
return
JSON
.
stringify
(
serialized
);
return
JSON
.
stringify
(
serialized
);
...
@@ -130,8 +132,9 @@ class UntitledEditorInputFactory implements IEditorInputFactory {
...
@@ -130,8 +132,9 @@ class UntitledEditorInputFactory implements IEditorInputFactory {
const
resource
=
!!
deserialized
.
resourceJSON
?
URI
.
revive
(
deserialized
.
resourceJSON
)
:
URI
.
parse
(
deserialized
.
resource
);
const
resource
=
!!
deserialized
.
resourceJSON
?
URI
.
revive
(
deserialized
.
resourceJSON
)
:
URI
.
parse
(
deserialized
.
resource
);
const
filePath
=
resource
.
scheme
===
'
file
'
?
resource
.
fsPath
:
void
0
;
const
filePath
=
resource
.
scheme
===
'
file
'
?
resource
.
fsPath
:
void
0
;
const
language
=
deserialized
.
modeId
;
const
language
=
deserialized
.
modeId
;
const
encoding
=
deserialized
.
encoding
;
return
accessor
.
get
(
IWorkbenchEditorService
).
createInput
({
resource
,
filePath
,
language
})
as
UntitledEditorInput
;
return
accessor
.
get
(
IWorkbenchEditorService
).
createInput
({
resource
,
filePath
,
language
,
encoding
})
as
UntitledEditorInput
;
});
});
}
}
}
}
...
...
src/vs/workbench/common/editor/untitledEditorInput.ts
浏览文件 @
c5e3c8f1
...
@@ -27,10 +27,7 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
...
@@ -27,10 +27,7 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
public
static
ID
:
string
=
'
workbench.editors.untitledEditorInput
'
;
public
static
ID
:
string
=
'
workbench.editors.untitledEditorInput
'
;
private
resource
:
URI
;
private
_hasAssociatedFilePath
:
boolean
;
private
_hasAssociatedFilePath
:
boolean
;
private
initialValue
:
string
;
private
modeId
:
string
;
private
cachedModel
:
UntitledEditorModel
;
private
cachedModel
:
UntitledEditorModel
;
private
modelResolve
:
TPromise
<
UntitledEditorModel
>
;
private
modelResolve
:
TPromise
<
UntitledEditorModel
>
;
...
@@ -40,10 +37,11 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
...
@@ -40,10 +37,11 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
private
toUnbind
:
IDisposable
[];
private
toUnbind
:
IDisposable
[];
constructor
(
constructor
(
resource
:
URI
,
private
resource
:
URI
,
hasAssociatedFilePath
:
boolean
,
hasAssociatedFilePath
:
boolean
,
modeId
:
string
,
private
modeId
:
string
,
initialValue
:
string
,
private
initialValue
:
string
,
private
preferredEncoding
:
string
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
ITextFileService
private
textFileService
:
ITextFileService
,
@
ITextFileService
private
textFileService
:
ITextFileService
,
...
@@ -51,11 +49,9 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
...
@@ -51,11 +49,9 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
)
{
)
{
super
();
super
();
this
.
resource
=
resource
;
this
.
initialValue
=
initialValue
;
this
.
_hasAssociatedFilePath
=
hasAssociatedFilePath
;
this
.
_hasAssociatedFilePath
=
hasAssociatedFilePath
;
this
.
modeId
=
modeId
;
this
.
toUnbind
=
[];
this
.
toUnbind
=
[];
this
.
_onDidModelChangeContent
=
new
Emitter
<
void
>
();
this
.
_onDidModelChangeContent
=
new
Emitter
<
void
>
();
this
.
_onDidModelChangeEncoding
=
new
Emitter
<
void
>
();
this
.
_onDidModelChangeEncoding
=
new
Emitter
<
void
>
();
}
}
...
@@ -146,10 +142,12 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
...
@@ -146,10 +142,12 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
return
this
.
cachedModel
.
getEncoding
();
return
this
.
cachedModel
.
getEncoding
();
}
}
return
null
;
return
this
.
preferredEncoding
;
}
}
public
setEncoding
(
encoding
:
string
,
mode
:
EncodingMode
/* ignored, we only have Encode */
):
void
{
public
setEncoding
(
encoding
:
string
,
mode
:
EncodingMode
/* ignored, we only have Encode */
):
void
{
this
.
preferredEncoding
=
encoding
;
if
(
this
.
cachedModel
)
{
if
(
this
.
cachedModel
)
{
this
.
cachedModel
.
setEncoding
(
encoding
);
this
.
cachedModel
.
setEncoding
(
encoding
);
}
}
...
@@ -170,7 +168,7 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
...
@@ -170,7 +168,7 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport
}
}
private
createModel
():
UntitledEditorModel
{
private
createModel
():
UntitledEditorModel
{
const
model
=
this
.
instantiationService
.
createInstance
(
UntitledEditorModel
,
this
.
modeId
,
this
.
resource
,
this
.
hasAssociatedFilePath
,
this
.
initialValue
);
const
model
=
this
.
instantiationService
.
createInstance
(
UntitledEditorModel
,
this
.
modeId
,
this
.
resource
,
this
.
hasAssociatedFilePath
,
this
.
initialValue
,
this
.
preferredEncoding
);
// re-emit some events from the model
// re-emit some events from the model
this
.
toUnbind
.
push
(
model
.
onDidChangeContent
(()
=>
this
.
_onDidModelChangeContent
.
fire
()));
this
.
toUnbind
.
push
(
model
.
onDidChangeContent
(()
=>
this
.
_onDidModelChangeContent
.
fire
()));
...
...
src/vs/workbench/common/editor/untitledEditorModel.ts
浏览文件 @
c5e3c8f1
...
@@ -38,16 +38,13 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin
...
@@ -38,16 +38,13 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin
private
contentChangeEventScheduler
:
RunOnceScheduler
;
private
contentChangeEventScheduler
:
RunOnceScheduler
;
private
configuredEncoding
:
string
;
private
configuredEncoding
:
string
;
private
preferredEncoding
:
string
;
private
hasAssociatedFilePath
:
boolean
;
private
initialValue
:
string
;
constructor
(
constructor
(
private
modeId
:
string
,
private
modeId
:
string
,
private
resource
:
URI
,
private
resource
:
URI
,
hasAssociatedFilePath
:
boolean
,
private
hasAssociatedFilePath
:
boolean
,
initialValue
:
string
,
private
initialValue
:
string
,
private
preferredEncoding
:
string
,
@
IModeService
modeService
:
IModeService
,
@
IModeService
modeService
:
IModeService
,
@
IModelService
modelService
:
IModelService
,
@
IModelService
modelService
:
IModelService
,
@
IBackupFileService
private
backupFileService
:
IBackupFileService
,
@
IBackupFileService
private
backupFileService
:
IBackupFileService
,
...
@@ -56,8 +53,6 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin
...
@@ -56,8 +53,6 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin
)
{
)
{
super
(
modelService
,
modeService
);
super
(
modelService
,
modeService
);
this
.
hasAssociatedFilePath
=
hasAssociatedFilePath
;
this
.
initialValue
=
initialValue
;
this
.
dirty
=
false
;
this
.
dirty
=
false
;
this
.
versionId
=
0
;
this
.
versionId
=
0
;
...
...
src/vs/workbench/parts/files/common/editors/fileEditorInput.ts
浏览文件 @
c5e3c8f1
...
@@ -27,8 +27,6 @@ import { ITextModelResolverService } from 'vs/editor/common/services/resolverSer
...
@@ -27,8 +27,6 @@ import { ITextModelResolverService } from 'vs/editor/common/services/resolverSer
* A file editor input is the input type for the file editor of file system resources.
* A file editor input is the input type for the file editor of file system resources.
*/
*/
export
class
FileEditorInput
extends
EditorInput
implements
IFileEditorInput
{
export
class
FileEditorInput
extends
EditorInput
implements
IFileEditorInput
{
private
resource
:
URI
;
private
preferredEncoding
:
string
;
private
forceOpenAsBinary
:
boolean
;
private
forceOpenAsBinary
:
boolean
;
private
textModelReference
:
TPromise
<
IReference
<
TextFileEditorModel
>>
;
private
textModelReference
:
TPromise
<
IReference
<
TextFileEditorModel
>>
;
...
@@ -46,8 +44,8 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
...
@@ -46,8 +44,8 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
* An editor input who's contents are retrieved from file services.
* An editor input who's contents are retrieved from file services.
*/
*/
constructor
(
constructor
(
resource
:
URI
,
private
resource
:
URI
,
preferredEncoding
:
string
,
pr
ivate
pr
eferredEncoding
:
string
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
ITextFileService
private
textFileService
:
ITextFileService
,
@
ITextFileService
private
textFileService
:
ITextFileService
,
...
@@ -58,9 +56,6 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
...
@@ -58,9 +56,6 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
this
.
toUnbind
=
[];
this
.
toUnbind
=
[];
this
.
resource
=
resource
;
this
.
preferredEncoding
=
preferredEncoding
;
this
.
registerListeners
();
this
.
registerListeners
();
}
}
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
c5e3c8f1
...
@@ -233,7 +233,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
...
@@ -233,7 +233,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
// Untitled file support
// Untitled file support
const
untitledInput
=
<
IUntitledResourceInput
>
input
;
const
untitledInput
=
<
IUntitledResourceInput
>
input
;
if
(
!
untitledInput
.
resource
||
typeof
untitledInput
.
filePath
===
'
string
'
||
(
untitledInput
.
resource
instanceof
URI
&&
untitledInput
.
resource
.
scheme
===
UNTITLED_SCHEMA
))
{
if
(
!
untitledInput
.
resource
||
typeof
untitledInput
.
filePath
===
'
string
'
||
(
untitledInput
.
resource
instanceof
URI
&&
untitledInput
.
resource
.
scheme
===
UNTITLED_SCHEMA
))
{
return
this
.
untitledEditorService
.
createOrGet
(
untitledInput
.
filePath
?
URI
.
file
(
untitledInput
.
filePath
)
:
untitledInput
.
resource
,
untitledInput
.
language
,
untitledInput
.
contents
);
return
this
.
untitledEditorService
.
createOrGet
(
untitledInput
.
filePath
?
URI
.
file
(
untitledInput
.
filePath
)
:
untitledInput
.
resource
,
untitledInput
.
language
,
untitledInput
.
contents
,
untitledInput
.
encoding
);
}
}
const
resourceInput
=
<
IResourceInput
>
input
;
const
resourceInput
=
<
IResourceInput
>
input
;
...
...
src/vs/workbench/services/untitled/common/untitledEditorService.ts
浏览文件 @
c5e3c8f1
...
@@ -24,6 +24,7 @@ export interface IModelLoadOrCreateOptions {
...
@@ -24,6 +24,7 @@ export interface IModelLoadOrCreateOptions {
resource
?:
URI
;
resource
?:
URI
;
modeId
?:
string
;
modeId
?:
string
;
initialValue
?:
string
;
initialValue
?:
string
;
encoding
?:
string
;
}
}
export
interface
IUntitledEditorService
{
export
interface
IUntitledEditorService
{
...
@@ -77,7 +78,7 @@ export interface IUntitledEditorService {
...
@@ -77,7 +78,7 @@ export interface IUntitledEditorService {
* It is valid to pass in a file resource. In that case the path will be used as identifier.
* It is valid to pass in a file resource. In that case the path will be used as identifier.
* The use case is to be able to create a new file with a specific path with VSCode.
* The use case is to be able to create a new file with a specific path with VSCode.
*/
*/
createOrGet
(
resource
?:
URI
,
modeId
?:
string
,
initialValue
?:
string
):
UntitledEditorInput
;
createOrGet
(
resource
?:
URI
,
modeId
?:
string
,
initialValue
?:
string
,
encoding
?:
string
):
UntitledEditorInput
;
/**
/**
* Creates a new untitled model with the optional resource URI or returns an existing one
* Creates a new untitled model with the optional resource URI or returns an existing one
...
@@ -194,10 +195,10 @@ export class UntitledEditorService implements IUntitledEditorService {
...
@@ -194,10 +195,10 @@ export class UntitledEditorService implements IUntitledEditorService {
}
}
public
loadOrCreate
(
options
:
IModelLoadOrCreateOptions
=
Object
.
create
(
null
)):
TPromise
<
UntitledEditorModel
>
{
public
loadOrCreate
(
options
:
IModelLoadOrCreateOptions
=
Object
.
create
(
null
)):
TPromise
<
UntitledEditorModel
>
{
return
this
.
createOrGet
(
options
.
resource
,
options
.
modeId
,
options
.
initialValue
).
resolve
();
return
this
.
createOrGet
(
options
.
resource
,
options
.
modeId
,
options
.
initialValue
,
options
.
encoding
).
resolve
();
}
}
public
createOrGet
(
resource
?:
URI
,
modeId
?:
string
,
initialValue
?:
string
):
UntitledEditorInput
{
public
createOrGet
(
resource
?:
URI
,
modeId
?:
string
,
initialValue
?:
string
,
encoding
?:
string
):
UntitledEditorInput
{
// Massage resource if it comes with a file:// scheme
// Massage resource if it comes with a file:// scheme
let
hasAssociatedFilePath
=
false
;
let
hasAssociatedFilePath
=
false
;
...
@@ -216,10 +217,10 @@ export class UntitledEditorService implements IUntitledEditorService {
...
@@ -216,10 +217,10 @@ export class UntitledEditorService implements IUntitledEditorService {
}
}
// Create new otherwise
// Create new otherwise
return
this
.
doCreate
(
resource
,
hasAssociatedFilePath
,
modeId
,
initialValue
);
return
this
.
doCreate
(
resource
,
hasAssociatedFilePath
,
modeId
,
initialValue
,
encoding
);
}
}
private
doCreate
(
resource
?:
URI
,
hasAssociatedFilePath
?:
boolean
,
modeId
?:
string
,
initialValue
?:
string
):
UntitledEditorInput
{
private
doCreate
(
resource
?:
URI
,
hasAssociatedFilePath
?:
boolean
,
modeId
?:
string
,
initialValue
?:
string
,
encoding
?:
string
):
UntitledEditorInput
{
if
(
!
resource
)
{
if
(
!
resource
)
{
// Create new taking a resource URI that is not already taken
// Create new taking a resource URI that is not already taken
...
@@ -238,7 +239,7 @@ export class UntitledEditorService implements IUntitledEditorService {
...
@@ -238,7 +239,7 @@ export class UntitledEditorService implements IUntitledEditorService {
}
}
}
}
const
input
=
this
.
instantiationService
.
createInstance
(
UntitledEditorInput
,
resource
,
hasAssociatedFilePath
,
modeId
,
initialValue
);
const
input
=
this
.
instantiationService
.
createInstance
(
UntitledEditorInput
,
resource
,
hasAssociatedFilePath
,
modeId
,
initialValue
,
encoding
);
const
contentListener
=
input
.
onDidModelChangeContent
(()
=>
{
const
contentListener
=
input
.
onDidModelChangeContent
(()
=>
{
this
.
_onDidChangeContent
.
fire
(
resource
);
this
.
_onDidChangeContent
.
fire
(
resource
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录