Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
8d349677
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,发现更多精彩内容 >>
提交
8d349677
编写于
2月 11, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Speed up editorStatus: do minimal updates to the DOM
上级
c9676af8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
143 addition
and
55 deletion
+143
-55
src/vs/workbench/browser/parts/editor/editorStatus.ts
src/vs/workbench/browser/parts/editor/editorStatus.ts
+143
-55
未找到文件。
src/vs/workbench/browser/parts/editor/editorStatus.ts
浏览文件 @
8d349677
...
...
@@ -9,7 +9,6 @@ import 'vs/css!./media/editorstatus';
import
nls
=
require
(
'
vs/nls
'
);
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
emmet
as
$
,
append
,
show
,
hide
}
from
'
vs/base/browser/dom
'
;
import
objects
=
require
(
'
vs/base/common/objects
'
);
import
encoding
=
require
(
'
vs/base/common/bits/encoding
'
);
import
strings
=
require
(
'
vs/base/common/strings
'
);
import
types
=
require
(
'
vs/base/common/types
'
);
...
...
@@ -65,14 +64,99 @@ interface IEditorSelectionStatus {
charactersSelected
?:
number
;
}
interface
IState
{
selectionStatus
:
IEditorSelectionStatus
;
mode
:
string
;
encoding
:
string
;
EOL
:
string
;
interface
IState
Change
{
selectionStatus
:
boolean
;
mode
:
boolean
;
encoding
:
boolean
;
EOL
:
boolean
;
tabFocusMode
:
boolean
;
}
interface
StateDelta
{
selectionStatus
?:
string
;
mode
?:
string
;
encoding
?:
string
;
EOL
?:
string
;
tabFocusMode
?:
boolean
;
}
class
State
{
private
_selectionStatus
:
string
;
public
get
selectionStatus
():
string
{
return
this
.
_selectionStatus
;
}
private
_mode
:
string
;
public
get
mode
():
string
{
return
this
.
_mode
;
}
private
_encoding
:
string
;
public
get
encoding
():
string
{
return
this
.
_encoding
;
}
private
_EOL
:
string
;
public
get
EOL
():
string
{
return
this
.
_EOL
;
}
private
_tabFocusMode
:
boolean
;
public
get
tabFocusMode
():
boolean
{
return
this
.
_tabFocusMode
;
}
constructor
()
{
this
.
_selectionStatus
=
null
;
this
.
_mode
=
null
;
this
.
_encoding
=
null
;
this
.
_EOL
=
null
;
this
.
_tabFocusMode
=
false
;
}
public
update
(
update
:
StateDelta
):
IStateChange
{
let
e
=
{
selectionStatus
:
false
,
mode
:
false
,
encoding
:
false
,
EOL
:
false
,
tabFocusMode
:
false
};
let
somethingChanged
=
false
;
if
(
typeof
update
.
selectionStatus
!==
'
undefined
'
)
{
if
(
this
.
_selectionStatus
!==
update
.
selectionStatus
)
{
this
.
_selectionStatus
=
update
.
selectionStatus
;
somethingChanged
=
true
;
e
.
selectionStatus
=
true
;
}
}
if
(
typeof
update
.
mode
!==
'
undefined
'
)
{
if
(
this
.
_mode
!==
update
.
mode
)
{
this
.
_mode
=
update
.
mode
;
somethingChanged
=
true
;
e
.
mode
=
true
;
}
}
if
(
typeof
update
.
encoding
!==
'
undefined
'
)
{
if
(
this
.
_encoding
!==
update
.
encoding
)
{
this
.
_encoding
=
update
.
encoding
;
somethingChanged
=
true
;
e
.
encoding
=
true
;
}
}
if
(
typeof
update
.
EOL
!==
'
undefined
'
)
{
if
(
this
.
_EOL
!==
update
.
EOL
)
{
this
.
_EOL
=
update
.
EOL
;
somethingChanged
=
true
;
e
.
EOL
=
true
;
}
}
if
(
typeof
update
.
tabFocusMode
!==
'
undefined
'
)
{
if
(
this
.
_tabFocusMode
!==
update
.
tabFocusMode
)
{
this
.
_tabFocusMode
=
update
.
tabFocusMode
;
somethingChanged
=
true
;
e
.
tabFocusMode
=
true
;
}
}
if
(
somethingChanged
)
{
return
e
;
}
return
null
;
}
}
const
nlsSingleSelectionRange
=
nls
.
localize
(
'
singleSelectionRange
'
,
"
Ln {0}, Col {1} ({2} selected)
"
);
const
nlsSingleSelection
=
nls
.
localize
(
'
singleSelection
'
,
"
Ln {0}, Col {1}
"
);
const
nlsMultiSelectionRange
=
nls
.
localize
(
'
multiSelectionRange
'
,
"
{0} selections ({1} characters selected)
"
);
...
...
@@ -83,7 +167,7 @@ const nlsTabFocusMode = nls.localize('tabFocusModeEnabled', "Tab moves focus");
export
class
EditorStatus
implements
IStatusbarItem
{
private
state
:
I
State
;
private
state
:
State
;
private
element
:
HTMLElement
;
private
tabFocusModeElement
:
HTMLElement
;
private
selectionElement
:
HTMLElement
;
...
...
@@ -99,13 +183,7 @@ export class EditorStatus implements IStatusbarItem {
@
IEventService
private
eventService
:
IEventService
)
{
this
.
toDispose
=
[];
this
.
state
=
{
selectionStatus
:
null
,
mode
:
null
,
encoding
:
null
,
EOL
:
null
,
tabFocusMode
:
false
,
};
this
.
state
=
new
State
();
}
public
render
(
container
:
HTMLElement
):
IDisposable
{
...
...
@@ -115,24 +193,27 @@ export class EditorStatus implements IStatusbarItem {
this
.
tabFocusModeElement
.
title
=
nls
.
localize
(
'
disableTabMode
'
,
"
Disable Accessibility Mode
"
);
this
.
tabFocusModeElement
.
onclick
=
()
=>
this
.
onTabFocusModeClick
();
this
.
tabFocusModeElement
.
textContent
=
nlsTabFocusMode
;
hide
(
this
.
tabFocusModeElement
);
this
.
selectionElement
=
append
(
this
.
element
,
$
(
'
a.editor-status-selection
'
));
this
.
selectionElement
.
title
=
nls
.
localize
(
'
gotoLine
'
,
"
Go to Line
"
);
this
.
selectionElement
.
onclick
=
()
=>
this
.
onSelectionClick
();
hide
(
this
.
selectionElement
);
this
.
encodingElement
=
append
(
this
.
element
,
$
(
'
a.editor-status-encoding
'
));
this
.
encodingElement
.
title
=
nls
.
localize
(
'
selectEncoding
'
,
"
Select Encoding
"
);
this
.
encodingElement
.
onclick
=
()
=>
this
.
onEncodingClick
();
hide
(
this
.
encodingElement
);
this
.
eolElement
=
append
(
this
.
element
,
$
(
'
a.editor-status-eol
'
));
this
.
eolElement
.
title
=
nls
.
localize
(
'
selectEOL
'
,
"
Select End of Line Sequence
"
);
this
.
eolElement
.
onclick
=
()
=>
this
.
onEOLClick
();
hide
(
this
.
eolElement
);
this
.
modeElement
=
append
(
this
.
element
,
$
(
'
a.editor-status-mode
'
));
this
.
modeElement
.
title
=
nls
.
localize
(
'
selectLanguageMode
'
,
"
Select Language Mode
"
);
this
.
modeElement
.
onclick
=
()
=>
this
.
onModeClick
();
this
.
setState
(
this
.
state
);
hide
(
this
.
modeElement
);
this
.
toDispose
.
push
(
this
.
eventService
.
addListener2
(
EventType
.
EDITOR_INPUT_CHANGED
,
(
e
:
EditorEvent
)
=>
this
.
onEditorInputChange
(
e
.
editor
)),
...
...
@@ -146,52 +227,59 @@ export class EditorStatus implements IStatusbarItem {
return
combinedDispose
(...
this
.
toDispose
);
}
private
setState
(
state
:
IState
):
void
{
this
.
state
=
state
;
if
(
state
.
tabFocusMode
&&
state
.
tabFocusMode
===
true
)
{
show
(
this
.
tabFocusModeElement
);
}
else
{
hide
(
this
.
tabFocusModeElement
);
private
updateState
(
update
:
StateDelta
):
void
{
let
changed
=
this
.
state
.
update
(
update
);
if
(
!
changed
)
{
// Nothing really changed
return
;
}
let
selectionLabel
=
this
.
getSelectionLabel
();
if
(
selectionLabel
)
{
this
.
selectionElement
.
textContent
=
selectionLabel
;
show
(
this
.
selectionElement
);
}
else
{
hide
(
this
.
selectionElement
);
if
(
changed
.
tabFocusMode
)
{
if
(
this
.
state
.
tabFocusMode
&&
this
.
state
.
tabFocusMode
===
true
)
{
show
(
this
.
tabFocusModeElement
)
;
}
else
{
hide
(
this
.
tabFocusModeElement
);
}
}
if
(
state
.
encoding
)
{
this
.
encodingElement
.
textContent
=
state
.
encoding
;
show
(
this
.
encodingElement
);
}
else
{
hide
(
this
.
encodingElement
);
if
(
changed
.
selectionStatus
)
{
if
(
this
.
state
.
selectionStatus
)
{
this
.
selectionElement
.
textContent
=
this
.
state
.
selectionStatus
;
show
(
this
.
selectionElement
);
}
else
{
hide
(
this
.
selectionElement
);
}
}
if
(
state
.
EOL
)
{
this
.
eolElement
.
textContent
=
state
.
EOL
===
'
\r\n
'
?
nlsEOLCRLF
:
nlsEOLLF
;
show
(
this
.
eolElement
);
}
else
{
hide
(
this
.
eolElement
);
if
(
changed
.
encoding
)
{
if
(
this
.
state
.
encoding
)
{
this
.
encodingElement
.
textContent
=
this
.
state
.
encoding
;
show
(
this
.
encodingElement
);
}
else
{
hide
(
this
.
encodingElement
);
}
}
if
(
state
.
mode
)
{
this
.
modeElement
.
textContent
=
state
.
mode
;
show
(
this
.
modeElement
);
}
else
{
hide
(
this
.
modeElement
);
if
(
changed
.
EOL
)
{
if
(
this
.
state
.
EOL
)
{
this
.
eolElement
.
textContent
=
this
.
state
.
EOL
===
'
\r\n
'
?
nlsEOLCRLF
:
nlsEOLLF
;
show
(
this
.
eolElement
);
}
else
{
hide
(
this
.
eolElement
);
}
}
}
private
updateState
(
update
:
any
):
void
{
this
.
setState
(
objects
.
assign
({},
this
.
state
,
update
));
if
(
changed
.
mode
)
{
if
(
this
.
state
.
mode
)
{
this
.
modeElement
.
textContent
=
this
.
state
.
mode
;
show
(
this
.
modeElement
);
}
else
{
hide
(
this
.
modeElement
);
}
}
}
private
getSelectionLabel
():
string
{
let
info
=
this
.
state
.
selectionStatus
;
private
getSelectionLabel
(
info
:
IEditorSelectionStatus
):
string
{
if
(
!
info
||
!
info
.
selections
)
{
return
null
;
}
...
...
@@ -256,7 +344,7 @@ export class EditorStatus implements IStatusbarItem {
return
;
}
let
info
:
{
mode
:
string
;
}
=
{
mode
:
null
};
let
info
:
StateDelta
=
{
mode
:
null
};
// We only support text based editors
if
(
e
instanceof
BaseTextEditor
)
{
...
...
@@ -312,7 +400,7 @@ export class EditorStatus implements IStatusbarItem {
}
}
this
.
updateState
({
selectionStatus
:
info
});
this
.
updateState
({
selectionStatus
:
this
.
getSelectionLabel
(
info
)
});
}
private
onEOLChange
(
e
:
IBaseEditor
):
void
{
...
...
@@ -320,7 +408,7 @@ export class EditorStatus implements IStatusbarItem {
return
;
}
let
info
:
{
EOL
:
string
;
}
=
{
EOL
:
null
};
let
info
:
StateDelta
=
{
EOL
:
null
};
// We only support writable text based code editors
if
(
e
instanceof
BaseTextEditor
&&
isWritableCodeEditor
(
e
))
{
...
...
@@ -339,7 +427,7 @@ export class EditorStatus implements IStatusbarItem {
return
;
}
let
info
:
{
encoding
:
string
;
}
=
{
encoding
:
null
};
let
info
:
StateDelta
=
{
encoding
:
null
};
// We only support text based editors
if
(
e
instanceof
BaseTextEditor
)
{
...
...
@@ -373,7 +461,7 @@ export class EditorStatus implements IStatusbarItem {
return
;
}
let
info
:
{
tabFocusMode
:
boolean
;
}
=
{
tabFocusMode
:
false
};
let
info
:
StateDelta
=
{
tabFocusMode
:
false
};
// We only support text based editors
if
(
e
instanceof
BaseTextEditor
&&
isCodeEditorWithTabFocusMode
(
e
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录