Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
fd25c8a1
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,发现更多精彩内容 >>
提交
fd25c8a1
编写于
12月 11, 2015
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support encoding and lf/crlf from status bar for diff editor (fixes #1195)
上级
91e3b548
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
10 deletion
+24
-10
src/vs/workbench/browser/parts/editor/editorStatus.ts
src/vs/workbench/browser/parts/editor/editorStatus.ts
+24
-10
未找到文件。
src/vs/workbench/browser/parts/editor/editorStatus.ts
浏览文件 @
fd25c8a1
...
...
@@ -22,9 +22,9 @@ import {IEditorModesRegistry, Extensions} from 'vs/editor/common/modes/modesRegi
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
BaseEditor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
UntitledEditorInput
}
from
'
vs/workbench/browser/parts/editor/untitledEditorInput
'
;
import
{
EncodingMode
,
IEncodingSupport
,
asFileEditorInput
,
getUntitledOrFileResource
}
from
'
vs/workbench/common/editor
'
;
import
{
IFileEditorInput
,
EditorInput
,
EncodingMode
,
IEncodingSupport
,
asFileEditorInput
,
getUntitledOrFileResource
}
from
'
vs/workbench/common/editor
'
;
import
{
toDisposable
,
IDisposable
,
combinedDispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
,
IDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
EndOfLineSequence
,
ITokenizedModel
,
EditorType
,
IEditorSelection
,
ITextModel
,
IDiffEditorModel
,
IEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
EventType
,
EditorEvent
,
TextEditorSelectionEvent
,
ResourceEvent
}
from
'
vs/workbench/browser/events
'
;
import
{
BaseTextEditor
}
from
'
vs/workbench/browser/parts/editor/textEditor
'
;
...
...
@@ -53,6 +53,14 @@ function getTextModel(editorWidget: IEditor): ITextModel {
return
textModel
;
}
function
asFileOrUntitledEditorInput
(
input
:
any
):
UntitledEditorInput
|
IFileEditorInput
{
if
(
input
instanceof
UntitledEditorInput
)
{
return
input
;
}
return
asFileEditorInput
(
input
,
true
/* support diff editor */
);
}
interface
IEditorSelectionStatus
{
selections
?:
IEditorSelection
[];
charactersSelected
?:
number
;
...
...
@@ -336,7 +344,7 @@ export class EditorStatus implements IStatusbarItem {
// We only support text based editors
if
(
e
instanceof
BaseTextEditor
)
{
let
encodingSupport
:
IEncodingSupport
=
<
any
>
e
.
input
;
let
encodingSupport
:
IEncodingSupport
=
<
any
>
asFileOrUntitledEditorInput
(
e
.
input
)
;
if
(
encodingSupport
&&
types
.
isFunction
(
encodingSupport
.
getEncoding
))
{
let
rawEncoding
=
encodingSupport
.
getEncoding
();
let
encodingInfo
=
encoding
.
SUPPORTED_ENCODINGS
[
rawEncoding
];
...
...
@@ -379,7 +387,7 @@ export class EditorStatus implements IStatusbarItem {
private
getActiveEditor
(
resource
:
uri
):
BaseEditor
{
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
)
{
let
r
=
getUntitledOrFileResource
(
activeEditor
.
input
);
let
r
=
getUntitledOrFileResource
(
activeEditor
.
input
,
true
);
if
(
r
&&
r
.
toString
()
===
resource
.
toString
())
{
return
<
BaseEditor
>
activeEditor
;
}
...
...
@@ -391,12 +399,20 @@ export class EditorStatus implements IStatusbarItem {
function
isCodeEditorWithTabFocusMode
(
e
:
BaseTextEditor
):
boolean
{
let
editorWidget
=
e
.
getControl
();
if
(
editorWidget
.
getEditorType
()
===
EditorType
.
IDiffEditor
)
{
editorWidget
=
(
<
IDiffEditor
>
editorWidget
).
getModifiedEditor
();
}
return
(
editorWidget
.
getEditorType
()
===
EditorType
.
ICodeEditor
&&
(
<
ICodeEditor
>
editorWidget
).
getConfiguration
().
tabFocusMode
);
}
function
isWritableCodeEditor
(
e
:
BaseTextEditor
):
boolean
{
let
editorWidget
=
e
.
getControl
();
if
(
editorWidget
.
getEditorType
()
===
EditorType
.
IDiffEditor
)
{
editorWidget
=
(
<
IDiffEditor
>
editorWidget
).
getModifiedEditor
();
}
return
(
editorWidget
.
getEditorType
()
===
EditorType
.
ICodeEditor
&&
!
(
<
ICodeEditor
>
editorWidget
).
getConfiguration
().
readOnly
);
}
...
...
@@ -553,7 +569,7 @@ export class ChangeEncodingAction extends Action {
return
this
.
quickOpenService
.
pick
([{
label
:
nls
.
localize
(
'
noEditor
'
,
"
No text editor active at this time
"
)
}]);
}
let
encodingSupport
:
IEncodingSupport
=
<
any
>
a
ctiveEditor
.
input
;
let
encodingSupport
:
IEncodingSupport
=
<
any
>
a
sFileOrUntitledEditorInput
(
activeEditor
.
input
)
;
if
(
!
types
.
areFunctions
(
encodingSupport
.
setEncoding
,
encodingSupport
.
getEncoding
))
{
return
this
.
quickOpenService
.
pick
([{
label
:
nls
.
localize
(
'
noFileEditor
'
,
"
No file active at this time
"
)
}]);
}
...
...
@@ -562,7 +578,7 @@ export class ChangeEncodingAction extends Action {
let
saveWithEncodingPick
:
IPickOpenEntry
=
{
label
:
nls
.
localize
(
'
saveWithEncoding
'
,
"
Save with Encoding
"
)
};
let
reopenWithEncodingPick
:
IPickOpenEntry
=
{
label
:
nls
.
localize
(
'
reopenWithEncoding
'
,
"
Reopen with Encoding
"
)
};
if
(
activeEditor
.
inpu
t
instanceof
UntitledEditorInput
)
{
if
(
encodingSuppor
t
instanceof
UntitledEditorInput
)
{
pickActionPromise
=
Promise
.
as
(
saveWithEncodingPick
);
}
else
if
(
!
isWritableCodeEditor
(
<
BaseTextEditor
>
activeEditor
))
{
pickActionPromise
=
Promise
.
as
(
reopenWithEncodingPick
);
...
...
@@ -607,11 +623,9 @@ export class ChangeEncodingAction extends Action {
}).
then
((
encoding
)
=>
{
if
(
encoding
)
{
activeEditor
=
this
.
editorService
.
getActiveEditor
();
encodingSupport
=
<
any
>
a
ctiveEditor
.
input
;
encodingSupport
=
<
any
>
a
sFileOrUntitledEditorInput
(
activeEditor
.
input
)
;
if
(
encodingSupport
&&
types
.
areFunctions
(
encodingSupport
.
setEncoding
,
encodingSupport
.
getEncoding
)
&&
encodingSupport
.
getEncoding
()
!==
encoding
.
id
)
{
// Set new encoding
encodingSupport
.
setEncoding
(
encoding
.
id
,
isReopenWithEncoding
?
EncodingMode
.
Decode
:
EncodingMode
.
Encode
);
encodingSupport
.
setEncoding
(
encoding
.
id
,
isReopenWithEncoding
?
EncodingMode
.
Decode
:
EncodingMode
.
Encode
);
// Set new encoding
}
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录