Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e7871ead
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,发现更多精彩内容 >>
提交
e7871ead
编写于
8月 10, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#55803 - Don't refresh a setting currently being edited
上级
03cfde3d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
32 deletion
+31
-32
src/vs/base/browser/dom.ts
src/vs/base/browser/dom.ts
+1
-1
src/vs/workbench/parts/preferences/browser/settingsEditor2.ts
...vs/workbench/parts/preferences/browser/settingsEditor2.ts
+30
-31
未找到文件。
src/vs/base/browser/dom.ts
浏览文件 @
e7871ead
...
...
@@ -920,7 +920,7 @@ class FocusTracker implements IFocusTracker {
private
disposables
:
IDisposable
[]
=
[];
constructor
(
element
:
HTMLElement
|
Window
)
{
let
hasFocus
=
false
;
let
hasFocus
=
document
.
activeElement
===
element
;
let
loosingFocus
=
false
;
let
onFocus
=
()
=>
{
...
...
src/vs/workbench/parts/preferences/browser/settingsEditor2.ts
浏览文件 @
e7871ead
...
...
@@ -82,6 +82,8 @@ export class SettingsEditor2 extends BaseEditor {
private
inSettingsEditorContextKey
:
IContextKey
<
boolean
>
;
private
searchFocusContextKey
:
IContextKey
<
boolean
>
;
private
scheduledRefreshTracker
:
DOM
.
IFocusTracker
;
private
tagRegex
=
/
(
^|
\s)
@tag:
(
"
([^
"
]
*
)
"|
[^
"
]\S
*
)
/g
;
/** Don't spam warnings */
...
...
@@ -149,7 +151,7 @@ export class SettingsEditor2 extends BaseEditor {
DOM
.
toggleClass
(
this
.
rootElement
,
'
narrow
'
,
dimension
.
width
<
600
);
this
.
delayRefreshOnLayout
.
trigger
(()
=>
this
.
refreshTree
AndMaintainFocus
());
this
.
delayRefreshOnLayout
.
trigger
(()
=>
this
.
refreshTree
());
}
focus
():
void
{
...
...
@@ -214,7 +216,7 @@ export class SettingsEditor2 extends BaseEditor {
this
.
toolbar
.
context
=
<
ISettingsToolbarContext
>
{
target
:
this
.
settingsTargetsWidget
.
settingsTarget
};
this
.
settingsTreeModel
.
update
();
this
.
refreshTree
AndMaintainFocus
();
this
.
refreshTree
();
});
this
.
createHeaderControls
(
headerControlsContainer
);
...
...
@@ -354,7 +356,7 @@ export class SettingsEditor2 extends BaseEditor {
const
element
=
e
.
focus
;
if
(
this
.
searchResultModel
)
{
this
.
viewState
.
filterToCategory
=
element
;
this
.
refreshTree
AndMaintainFocus
();
this
.
refreshTree
();
}
if
(
element
&&
(
!
e
.
payload
||
!
e
.
payload
.
fromScroll
))
{
...
...
@@ -464,7 +466,7 @@ export class SettingsEditor2 extends BaseEditor {
}
return
this
.
configurationService
.
updateValue
(
key
,
value
,
overrides
,
configurationTarget
)
.
then
(()
=>
this
.
refreshTree
AndMaintainFocus
())
.
then
(()
=>
this
.
refreshTree
())
.
then
(()
=>
{
const
reportModifiedProps
=
{
key
,
...
...
@@ -561,6 +563,19 @@ export class SettingsEditor2 extends BaseEditor {
}
}
private
scheduleRefresh
():
void
{
if
(
this
.
scheduledRefreshTracker
)
{
return
;
}
this
.
scheduledRefreshTracker
=
DOM
.
trackFocus
(
<
HTMLElement
>
document
.
activeElement
);
this
.
scheduledRefreshTracker
.
onDidBlur
(()
=>
{
this
.
scheduledRefreshTracker
.
dispose
();
this
.
scheduledRefreshTracker
=
null
;
this
.
refreshTree
();
});
}
private
onConfigUpdate
():
TPromise
<
void
>
{
const
groups
=
this
.
defaultSettingsEditorModel
.
settingsGroups
.
slice
(
1
);
// Without commonlyUsed
const
dividedGroups
=
collections
.
groupBy
(
groups
,
g
=>
g
.
contributedByExtension
?
'
extension
'
:
'
core
'
);
...
...
@@ -589,7 +604,7 @@ export class SettingsEditor2 extends BaseEditor {
if
(
this
.
settingsTreeModel
)
{
this
.
settingsTreeModel
.
update
(
resolvedSettingsRoot
);
return
this
.
refreshTree
AndMaintainFocus
();
return
this
.
refreshTree
();
}
else
{
this
.
settingsTreeModel
=
this
.
instantiationService
.
createInstance
(
SettingsTreeModel
,
this
.
viewState
,
resolvedSettingsRoot
);
this
.
settingsTree
.
setInput
(
this
.
settingsTreeModel
.
root
);
...
...
@@ -605,39 +620,23 @@ export class SettingsEditor2 extends BaseEditor {
return
TPromise
.
wrap
(
null
);
}
private
refreshTreeAndMaintainFocus
():
TPromise
<
any
>
{
// Sort of a hack to maintain focus on the focused control across a refresh
const
focusedRowItem
=
DOM
.
findParentWithClass
(
<
HTMLElement
>
document
.
activeElement
,
'
setting-item
'
);
const
focusedRowId
=
focusedRowItem
&&
focusedRowItem
.
id
;
const
selection
=
focusedRowId
&&
document
.
activeElement
.
tagName
.
toLowerCase
()
===
'
input
'
?
(
<
HTMLInputElement
>
document
.
activeElement
).
selectionStart
:
null
;
private
refreshTree
(
element
?:
SettingsTreeElement
):
TPromise
<
any
>
{
if
(
this
.
scheduledRefreshTracker
)
{
return
TPromise
.
wrap
(
null
);
}
if
(
document
.
activeElement
.
classList
.
contains
(
SettingsRenderer
.
CONTROL_CLASS
))
{
this
.
scheduleRefresh
();
return
TPromise
.
wrap
(
null
);
}
return
this
.
settingsTree
.
refresh
()
.
then
(()
=>
{
if
(
focusedRowId
)
{
this
.
focusEditControlForRow
(
focusedRowId
,
selection
);
}
})
.
then
(()
=>
{
// TODO@roblou - hack
this
.
tocTreeModel
.
update
();
return
this
.
tocTree
.
refresh
();
});
}
private
focusEditControlForRow
(
id
:
string
,
selection
?:
number
):
void
{
const
rowSelector
=
`.setting-item#
${
id
}
`
;
const
inputElementToFocus
:
HTMLElement
=
this
.
settingsTreeContainer
.
querySelector
(
`
${
rowSelector
}
input,
${
rowSelector
}
select,
${
rowSelector
}
.monaco-custom-checkbox`
);
if
(
inputElementToFocus
)
{
inputElementToFocus
.
focus
();
if
(
typeof
selection
===
'
number
'
)
{
(
<
HTMLInputElement
>
inputElementToFocus
).
setSelectionRange
(
selection
,
selection
);
}
}
}
private
onSearchInputChanged
():
void
{
const
query
=
this
.
searchWidget
.
getValue
().
trim
();
this
.
delayedFilterLogging
.
cancel
();
...
...
@@ -788,7 +787,7 @@ export class SettingsEditor2 extends BaseEditor {
this
.
tocTreeModel
.
update
();
expandAll
(
this
.
tocTree
);
resolve
(
this
.
refreshTree
AndMaintainFocus
());
resolve
(
this
.
refreshTree
());
});
},
()
=>
{
isCanceled
=
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录