Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
89a8ab2a
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,发现更多精彩内容 >>
提交
89a8ab2a
编写于
9月 05, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code cleanup
上级
194fa300
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
54 addition
and
51 deletion
+54
-51
src/vs/workbench/browser/parts/editor/editorStatus.ts
src/vs/workbench/browser/parts/editor/editorStatus.ts
+47
-48
src/vs/workbench/parts/files/browser/editors/textFileEditor.ts
...s/workbench/parts/files/browser/editors/textFileEditor.ts
+7
-3
未找到文件。
src/vs/workbench/browser/parts/editor/editorStatus.ts
浏览文件 @
89a8ab2a
...
...
@@ -8,7 +8,7 @@
import
'
vs/css!./media/editorstatus
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
$
,
append
,
runAtThisOrScheduleAtNextAnimationFrame
}
from
'
vs/base/browser/dom
'
;
import
{
$
,
append
,
runAtThisOrScheduleAtNextAnimationFrame
}
from
'
vs/base/browser/dom
'
;
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
types
=
require
(
'
vs/base/common/types
'
);
...
...
@@ -59,7 +59,7 @@ function getTextModel(editorWidget: IEditor): ITextModel {
let
textModel
:
ITextModel
;
// Support for diff
le
t
model
=
editorWidget
.
getModel
();
cons
t
model
=
editorWidget
.
getModel
();
if
(
model
&&
!!
(
<
IDiffEditorModel
>
model
).
modified
)
{
textModel
=
(
<
IDiffEditorModel
>
model
).
modified
;
}
...
...
@@ -151,7 +151,7 @@ class State {
}
public
update
(
update
:
StateDelta
):
StateChange
{
le
t
e
=
new
StateChange
();
cons
t
e
=
new
StateChange
();
let
somethingChanged
=
false
;
if
(
typeof
update
.
selectionStatus
!==
'
undefined
'
)
{
...
...
@@ -303,7 +303,7 @@ export class EditorStatus implements IStatusbarItem {
}
private
updateState
(
update
:
StateDelta
):
void
{
le
t
changed
=
this
.
state
.
update
(
update
);
cons
t
changed
=
this
.
state
.
update
(
update
);
if
(
!
changed
)
{
// Nothing really changed
return
;
...
...
@@ -313,7 +313,7 @@ export class EditorStatus implements IStatusbarItem {
this
.
toRender
=
changed
;
this
.
delayedRender
=
runAtThisOrScheduleAtNextAnimationFrame
(()
=>
{
this
.
delayedRender
=
null
;
le
t
toRender
=
this
.
toRender
;
cons
t
toRender
=
this
.
toRender
;
this
.
toRender
=
null
;
this
.
_renderNow
(
toRender
);
});
...
...
@@ -391,14 +391,14 @@ export class EditorStatus implements IStatusbarItem {
}
else
{
if
(
info
.
charactersSelected
)
{
return
strings
.
format
(
nlsMultiSelectionRange
,
info
.
selections
.
length
,
info
.
charactersSelected
);
}
else
{
}
else
if
(
info
.
selections
.
length
>
0
)
{
return
strings
.
format
(
nlsMultiSelection
,
info
.
selections
.
length
);
}
}
}
private
onModeClick
():
void
{
le
t
action
=
this
.
instantiationService
.
createInstance
(
ChangeModeAction
,
ChangeModeAction
.
ID
,
ChangeModeAction
.
LABEL
);
cons
t
action
=
this
.
instantiationService
.
createInstance
(
ChangeModeAction
,
ChangeModeAction
.
ID
,
ChangeModeAction
.
LABEL
);
action
.
run
().
done
(
null
,
errors
.
onUnexpectedError
);
action
.
dispose
();
...
...
@@ -415,14 +415,14 @@ export class EditorStatus implements IStatusbarItem {
}
private
onEOLClick
():
void
{
le
t
action
=
this
.
instantiationService
.
createInstance
(
ChangeEOLAction
,
ChangeEOLAction
.
ID
,
ChangeEOLAction
.
LABEL
);
cons
t
action
=
this
.
instantiationService
.
createInstance
(
ChangeEOLAction
,
ChangeEOLAction
.
ID
,
ChangeEOLAction
.
LABEL
);
action
.
run
().
done
(
null
,
errors
.
onUnexpectedError
);
action
.
dispose
();
}
private
onEncodingClick
():
void
{
le
t
action
=
this
.
instantiationService
.
createInstance
(
ChangeEncodingAction
,
ChangeEncodingAction
.
ID
,
ChangeEncodingAction
.
LABEL
);
cons
t
action
=
this
.
instantiationService
.
createInstance
(
ChangeEncodingAction
,
ChangeEncodingAction
.
ID
,
ChangeEncodingAction
.
LABEL
);
action
.
run
().
done
(
null
,
errors
.
onUnexpectedError
);
action
.
dispose
();
...
...
@@ -480,11 +480,11 @@ export class EditorStatus implements IStatusbarItem {
// We only support text based editors
if
(
editorWidget
)
{
le
t
textModel
=
getTextModel
(
editorWidget
);
cons
t
textModel
=
getTextModel
(
editorWidget
);
if
(
textModel
)
{
// Compute mode
if
(
!!
(
<
ITokenizedModel
>
textModel
).
getMode
)
{
le
t
mode
=
(
<
ITokenizedModel
>
textModel
).
getMode
();
cons
t
mode
=
(
<
ITokenizedModel
>
textModel
).
getMode
();
if
(
mode
)
{
info
=
{
mode
:
this
.
modeService
.
getLanguageName
(
mode
.
getId
())
};
}
...
...
@@ -518,7 +518,7 @@ export class EditorStatus implements IStatusbarItem {
}
private
onSelectionChange
(
editorWidget
?:
IEditor
):
void
{
le
t
info
:
IEditorSelectionStatus
=
{};
cons
t
info
:
IEditorSelectionStatus
=
{};
// We only support text based editors
if
(
editorWidget
)
{
...
...
@@ -528,7 +528,7 @@ export class EditorStatus implements IStatusbarItem {
// Compute selection length
info
.
charactersSelected
=
0
;
le
t
textModel
=
getTextModel
(
editorWidget
);
cons
t
textModel
=
getTextModel
(
editorWidget
);
if
(
textModel
)
{
info
.
selections
.
forEach
((
selection
)
=>
{
info
.
charactersSelected
+=
textModel
.
getValueLengthInRange
(
selection
);
...
...
@@ -537,9 +537,9 @@ export class EditorStatus implements IStatusbarItem {
// Compute the visible column for one selection. This will properly handle tabs and their configured widths
if
(
info
.
selections
.
length
===
1
)
{
le
t
visibleColumn
=
editorWidget
.
getVisibleColumnFromPosition
(
editorWidget
.
getPosition
());
cons
t
visibleColumn
=
editorWidget
.
getVisibleColumnFromPosition
(
editorWidget
.
getPosition
());
le
t
selectionClone
=
info
.
selections
[
0
].
clone
();
// do not modify the original position we got from the editor
cons
t
selectionClone
=
info
.
selections
[
0
].
clone
();
// do not modify the original position we got from the editor
selectionClone
.
positionColumn
=
visibleColumn
;
info
.
selections
[
0
]
=
selectionClone
;
...
...
@@ -550,11 +550,11 @@ export class EditorStatus implements IStatusbarItem {
}
private
onEOLChange
(
editorWidget
?:
IEditor
):
void
{
le
t
info
:
StateDelta
=
{
EOL
:
null
};
cons
t
info
:
StateDelta
=
{
EOL
:
null
};
le
t
codeEditor
=
getCodeEditor
(
editorWidget
);
cons
t
codeEditor
=
getCodeEditor
(
editorWidget
);
if
(
codeEditor
&&
!
codeEditor
.
getConfiguration
().
readOnly
)
{
le
t
codeEditorModel
=
codeEditor
.
getModel
();
cons
t
codeEditorModel
=
codeEditor
.
getModel
();
if
(
codeEditorModel
)
{
info
.
EOL
=
codeEditorModel
.
getEOL
();
}
...
...
@@ -568,14 +568,14 @@ export class EditorStatus implements IStatusbarItem {
return
;
}
le
t
info
:
StateDelta
=
{
encoding
:
null
};
cons
t
info
:
StateDelta
=
{
encoding
:
null
};
// We only support text based editors
if
(
e
instanceof
BaseTextEditor
)
{
le
t
encodingSupport
:
IEncodingSupport
=
<
any
>
asFileOrUntitledEditorInput
(
e
.
input
);
cons
t
encodingSupport
:
IEncodingSupport
=
<
any
>
asFileOrUntitledEditorInput
(
e
.
input
);
if
(
encodingSupport
&&
types
.
isFunction
(
encodingSupport
.
getEncoding
))
{
le
t
rawEncoding
=
encodingSupport
.
getEncoding
();
le
t
encodingInfo
=
SUPPORTED_ENCODINGS
[
rawEncoding
];
cons
t
rawEncoding
=
encodingSupport
.
getEncoding
();
cons
t
encodingInfo
=
SUPPORTED_ENCODINGS
[
rawEncoding
];
if
(
encodingInfo
)
{
info
.
encoding
=
encodingInfo
.
labelShort
;
// if we have a label, take it from there
}
else
{
...
...
@@ -588,9 +588,9 @@ export class EditorStatus implements IStatusbarItem {
}
private
onResourceEncodingChange
(
resource
:
uri
):
void
{
le
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
cons
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
)
{
le
t
activeResource
=
getUntitledOrFileResource
(
activeEditor
.
input
,
true
);
cons
t
activeResource
=
getUntitledOrFileResource
(
activeEditor
.
input
,
true
);
if
(
activeResource
&&
activeResource
.
toString
()
===
resource
.
toString
())
{
return
this
.
onEncodingChange
(
<
IBaseEditor
>
activeEditor
);
// only update if the encoding changed for the active resource
}
...
...
@@ -598,13 +598,13 @@ export class EditorStatus implements IStatusbarItem {
}
private
onTabFocusModeChange
():
void
{
le
t
info
:
StateDelta
=
{
tabFocusMode
:
TabFocus
.
getTabFocusMode
()
};
cons
t
info
:
StateDelta
=
{
tabFocusMode
:
TabFocus
.
getTabFocusMode
()
};
this
.
updateState
(
info
);
}
private
isActiveEditor
(
e
:
IBaseEditor
):
boolean
{
le
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
cons
t
activeEditor
=
this
.
editorService
.
getActiveEditor
();
return
activeEditor
&&
e
&&
activeEditor
===
e
;
}
...
...
@@ -638,27 +638,27 @@ export class ChangeModeAction extends Action {
}
public
run
():
TPromise
<
any
>
{
le
t
languages
=
this
.
modeService
.
getRegisteredLanguageNames
();
cons
t
languages
=
this
.
modeService
.
getRegisteredLanguageNames
();
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
!
(
activeEditor
instanceof
BaseTextEditor
))
{
return
this
.
quickOpenService
.
pick
([{
label
:
nls
.
localize
(
'
noEditor
'
,
"
No text editor active at this time
"
)
}]);
}
le
t
editorWidget
=
(
<
BaseTextEditor
>
activeEditor
).
getControl
();
le
t
textModel
=
getTextModel
(
editorWidget
);
le
t
fileinput
=
asFileEditorInput
(
activeEditor
.
input
,
true
);
cons
t
editorWidget
=
(
<
BaseTextEditor
>
activeEditor
).
getControl
();
cons
t
textModel
=
getTextModel
(
editorWidget
);
cons
t
fileinput
=
asFileEditorInput
(
activeEditor
.
input
,
true
);
// Compute mode
let
currentModeId
:
string
;
if
(
!!
(
<
ITokenizedModel
>
textModel
).
getMode
)
{
le
t
mode
=
(
<
ITokenizedModel
>
textModel
).
getMode
();
cons
t
mode
=
(
<
ITokenizedModel
>
textModel
).
getMode
();
if
(
mode
)
{
currentModeId
=
this
.
modeService
.
getLanguageName
(
mode
.
getId
());
}
}
// All languages are valid picks
le
t
picks
:
IPickOpenEntry
[]
=
languages
.
sort
().
map
((
lang
,
index
)
=>
{
cons
t
picks
:
IPickOpenEntry
[]
=
languages
.
sort
().
map
((
lang
,
index
)
=>
{
return
{
label
:
lang
,
description
:
currentModeId
===
lang
?
nls
.
localize
(
'
configuredLanguage
'
,
"
Configured Language
"
)
:
void
0
...
...
@@ -676,13 +676,13 @@ export class ChangeModeAction extends Action {
}
}
le
t
configureModeAssociations
:
IPickOpenEntry
=
{
cons
t
configureModeAssociations
:
IPickOpenEntry
=
{
label
:
configureLabel
};
picks
.
unshift
(
configureModeAssociations
);
// Offer to "Auto Detect"
le
t
autoDetectMode
:
IPickOpenEntry
=
{
cons
t
autoDetectMode
:
IPickOpenEntry
=
{
label
:
nls
.
localize
(
'
autoDetect
'
,
"
Auto Detect
"
)
};
if
(
fileinput
)
{
...
...
@@ -693,14 +693,14 @@ export class ChangeModeAction extends Action {
if
(
language
)
{
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
instanceof
BaseTextEditor
)
{
le
t
editorWidget
=
activeEditor
.
getControl
();
le
t
models
:
ITextModel
[]
=
[];
cons
t
editorWidget
=
activeEditor
.
getControl
();
cons
t
models
:
ITextModel
[]
=
[];
le
t
textModel
=
getTextModel
(
editorWidget
);
cons
t
textModel
=
getTextModel
(
editorWidget
);
models
.
push
(
textModel
);
// Support for original side of diff
le
t
model
=
editorWidget
.
getModel
();
cons
t
model
=
editorWidget
.
getModel
();
if
(
model
&&
!!
(
<
IDiffEditorModel
>
model
).
original
)
{
models
.
push
((
<
IDiffEditorModel
>
model
).
original
);
}
...
...
@@ -799,7 +799,6 @@ export class ChangeEOLAction extends Action {
}
public
run
():
TPromise
<
any
>
{
let
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
!
(
activeEditor
instanceof
BaseTextEditor
))
{
return
this
.
quickOpenService
.
pick
([{
label
:
nls
.
localize
(
'
noEditor
'
,
"
No text editor active at this time
"
)
}]);
...
...
@@ -809,22 +808,22 @@ export class ChangeEOLAction extends Action {
return
this
.
quickOpenService
.
pick
([{
label
:
nls
.
localize
(
'
noWritableCodeEditor
'
,
"
The active code editor is read-only.
"
)
}]);
}
le
t
editorWidget
=
(
<
BaseTextEditor
>
activeEditor
).
getControl
();
le
t
textModel
=
getTextModel
(
editorWidget
);
cons
t
editorWidget
=
(
<
BaseTextEditor
>
activeEditor
).
getControl
();
cons
t
textModel
=
getTextModel
(
editorWidget
);
le
t
EOLOptions
:
IChangeEOLEntry
[]
=
[
cons
t
EOLOptions
:
IChangeEOLEntry
[]
=
[
{
label
:
nlsEOLLF
,
eol
:
EndOfLineSequence
.
LF
},
{
label
:
nlsEOLCRLF
,
eol
:
EndOfLineSequence
.
CRLF
},
];
le
t
selectedIndex
=
(
textModel
.
getEOL
()
===
'
\n
'
)
?
0
:
1
;
cons
t
selectedIndex
=
(
textModel
.
getEOL
()
===
'
\n
'
)
?
0
:
1
;
return
this
.
quickOpenService
.
pick
(
EOLOptions
,
{
placeHolder
:
nls
.
localize
(
'
pickEndOfLine
'
,
"
Select End of Line Sequence
"
),
autoFocus
:
{
autoFocusIndex
:
selectedIndex
}
}).
then
((
eol
)
=>
{
if
(
eol
)
{
activeEditor
=
this
.
editorService
.
getActiveEditor
();
if
(
activeEditor
instanceof
BaseTextEditor
&&
isWritableCodeEditor
(
activeEditor
))
{
le
t
editorWidget
=
activeEditor
.
getControl
();
le
t
textModel
=
getTextModel
(
editorWidget
);
cons
t
editorWidget
=
activeEditor
.
getControl
();
cons
t
textModel
=
getTextModel
(
editorWidget
);
textModel
.
setEOL
(
eol
.
eol
);
}
}
...
...
@@ -886,13 +885,13 @@ export class ChangeEncodingAction extends Action {
return
TPromise
.
timeout
(
50
/* quick open is sensitive to being opened so soon after another */
).
then
(()
=>
{
const
configuration
=
this
.
configurationService
.
getConfiguration
<
IFilesConfiguration
>
();
le
t
isReopenWithEncoding
=
(
action
===
reopenWithEncodingPick
);
le
t
configuredEncoding
=
configuration
&&
configuration
.
files
&&
configuration
.
files
.
encoding
;
cons
t
isReopenWithEncoding
=
(
action
===
reopenWithEncodingPick
);
cons
t
configuredEncoding
=
configuration
&&
configuration
.
files
&&
configuration
.
files
.
encoding
;
let
directMatchIndex
:
number
;
let
aliasMatchIndex
:
number
;
// All encodings are valid picks
le
t
picks
:
IPickOpenEntry
[]
=
Object
.
keys
(
SUPPORTED_ENCODINGS
)
cons
t
picks
:
IPickOpenEntry
[]
=
Object
.
keys
(
SUPPORTED_ENCODINGS
)
.
sort
((
k1
,
k2
)
=>
{
if
(
k1
===
configuredEncoding
)
{
return
-
1
;
...
...
src/vs/workbench/parts/files/browser/editors/textFileEditor.ts
浏览文件 @
89a8ab2a
...
...
@@ -122,10 +122,14 @@ export class TextFileEditor extends BaseTextEditor {
// Check Model state
const
textFileModel
=
<
TextFileEditorModel
>
resolvedModel
;
const
hasInput
=
!!
this
.
getInput
();
const
modelDisposed
=
textFileModel
.
isDisposed
();
const
inputChanged
=
(
<
FileEditorInput
>
this
.
getInput
()).
getResource
().
toString
()
!==
textFileModel
.
getResource
().
toString
();
if
(
!
this
.
getInput
()
||
// editor got hidden meanwhile
textFileModel
.
isDisposed
()
||
// input got disposed meanwhile
(
<
FileEditorInput
>
this
.
getInput
()).
getResource
().
toString
()
!==
textFileModel
.
getResource
().
toString
()
// a different input was set meanwhile
!
hasInput
||
// editor got hidden meanwhile
modelDisposed
||
// input got disposed meanwhile
inputChanged
// a different input was set meanwhile
)
{
return
null
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录