Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8162c25b
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,发现更多精彩内容 >>
提交
8162c25b
编写于
7月 31, 2019
作者:
P
Pine Wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #78241
上级
e81b51de
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
32 deletion
+32
-32
src/vs/workbench/contrib/preferences/browser/settingsTree.ts
src/vs/workbench/contrib/preferences/browser/settingsTree.ts
+15
-17
src/vs/workbench/contrib/preferences/browser/settingsWidgets.ts
.../workbench/contrib/preferences/browser/settingsWidgets.ts
+17
-15
未找到文件。
src/vs/workbench/contrib/preferences/browser/settingsTree.ts
浏览文件 @
8162c25b
...
...
@@ -702,29 +702,27 @@ export class SettingArrayRenderer extends AbstractSettingRenderer implements ITr
?
[...
template
.
context
.
scopeValue
]
:
[...
template
.
context
.
value
];
// Delete value
if
(
e
.
removeIndex
!==
undefined
)
{
if
(
!
e
.
value
&&
e
.
originalValue
&&
e
.
removeIndex
>
-
1
)
{
newValue
.
splice
(
e
.
removeIndex
,
1
);
if
(
e
.
targetIndex
!==
undefined
)
{
// Delete value
if
(
!
e
.
value
&&
e
.
originalValue
&&
e
.
targetIndex
>
-
1
)
{
newValue
.
splice
(
e
.
targetIndex
,
1
);
}
// Update value
else
if
(
e
.
value
&&
e
.
originalValue
)
{
if
(
e
.
targetIndex
>
-
1
)
{
newValue
[
e
.
targetIndex
]
=
e
.
value
;
}
// For some reason, we are updating and cannot find original value
// Just append the value in this case
else
{
newValue
.
push
(
e
.
value
);
}
}
}
// Add value
else
if
(
e
.
value
&&
!
e
.
originalValue
)
{
newValue
.
push
(
e
.
value
);
}
// Update value
else
if
(
e
.
value
&&
e
.
originalValue
)
{
const
valueIndex
=
newValue
.
indexOf
(
e
.
originalValue
);
if
(
valueIndex
>
-
1
)
{
newValue
[
valueIndex
]
=
e
.
value
;
}
// For some reason, we are updating and cannot find original value
// Just append the value in this case
else
{
newValue
.
push
(
e
.
value
);
}
}
if
(
template
.
context
.
defaultValue
&&
isArray
(
template
.
context
.
defaultValue
)
&&
...
...
src/vs/workbench/contrib/preferences/browser/settingsWidgets.ts
浏览文件 @
8162c25b
...
...
@@ -132,14 +132,16 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
}
});
type
EditKey
=
'
none
'
|
'
create
'
|
number
;
export
class
ListSettingListModel
{
private
_dataItems
:
IListDataItem
[]
=
[];
private
_editKey
:
string
|
null
;
private
_editKey
:
EditKey
;
private
_selectedIdx
:
number
|
null
;
get
items
():
IListViewItem
[]
{
const
items
=
this
.
_dataItems
.
map
((
item
,
i
)
=>
{
const
editing
=
item
.
value
===
this
.
_editKey
;
const
editing
=
typeof
this
.
_editKey
===
'
number
'
&&
this
.
_editKey
===
i
;
return
<
IListViewItem
>
{
...
item
,
editing
,
...
...
@@ -147,7 +149,7 @@ export class ListSettingListModel {
};
});
if
(
this
.
_editKey
===
''
)
{
if
(
this
.
_editKey
===
'
create
'
)
{
items
.
push
({
editing
:
true
,
selected
:
true
,
...
...
@@ -159,7 +161,7 @@ export class ListSettingListModel {
return
items
;
}
setEditKey
(
key
:
string
|
null
):
void
{
setEditKey
(
key
:
EditKey
):
void
{
this
.
_editKey
=
key
;
}
...
...
@@ -196,7 +198,7 @@ export interface IListChangeEvent {
originalValue
:
string
;
value
?:
string
;
sibling
?:
string
;
remove
Index
?:
number
;
target
Index
?:
number
;
}
export
class
ListSettingWidget
extends
Disposable
{
...
...
@@ -295,7 +297,7 @@ export class ListSettingWidget extends Disposable {
const
item
=
this
.
model
.
items
[
targetIdx
];
if
(
item
)
{
this
.
editSetting
(
item
.
value
);
this
.
editSetting
(
targetIdx
);
e
.
preventDefault
();
e
.
stopPropagation
();
}
...
...
@@ -349,24 +351,24 @@ export class ListSettingWidget extends Disposable {
enabled
:
true
,
id
:
'
workbench.action.removeListItem
'
,
tooltip
:
this
.
getLocalizedStrings
().
deleteActionTooltip
,
run
:
()
=>
this
.
_onDidChangeList
.
fire
({
originalValue
:
key
,
value
:
undefined
,
remove
Index
:
idx
})
run
:
()
=>
this
.
_onDidChangeList
.
fire
({
originalValue
:
key
,
value
:
undefined
,
target
Index
:
idx
})
};
}
private
createEditAction
(
key
:
string
):
IAction
{
private
createEditAction
(
idx
:
number
):
IAction
{
return
<
IAction
>
{
class
:
'
setting-listAction-edit
'
,
enabled
:
true
,
id
:
'
workbench.action.editListItem
'
,
tooltip
:
this
.
getLocalizedStrings
().
editActionTooltip
,
run
:
()
=>
{
this
.
editSetting
(
key
);
this
.
editSetting
(
idx
);
}
};
}
private
editSetting
(
key
:
string
):
void
{
this
.
model
.
setEditKey
(
key
);
private
editSetting
(
idx
:
number
):
void
{
this
.
model
.
setEditKey
(
idx
);
this
.
renderList
();
}
...
...
@@ -391,7 +393,7 @@ export class ListSettingWidget extends Disposable {
siblingElement
.
textContent
=
item
.
sibling
?
(
'
when:
'
+
item
.
sibling
)
:
null
;
actionBar
.
push
([
this
.
createEditAction
(
i
tem
.
value
),
this
.
createEditAction
(
i
dx
),
this
.
createDeleteAction
(
item
.
value
,
idx
)
],
{
icon
:
true
,
label
:
false
});
...
...
@@ -419,7 +421,7 @@ export class ListSettingWidget extends Disposable {
this
.
_register
(
attachButtonStyler
(
startAddButton
,
this
.
themeService
));
this
.
_register
(
startAddButton
.
onDidClick
(()
=>
{
this
.
model
.
setEditKey
(
''
);
this
.
model
.
setEditKey
(
'
create
'
);
this
.
renderList
();
}));
...
...
@@ -430,14 +432,14 @@ export class ListSettingWidget extends Disposable {
const
rowElement
=
$
(
'
.setting-list-edit-row
'
);
const
onSubmit
=
(
edited
:
boolean
)
=>
{
this
.
model
.
setEditKey
(
null
);
this
.
model
.
setEditKey
(
'
none
'
);
const
value
=
valueInput
.
value
.
trim
();
if
(
edited
&&
!
isUndefinedOrNull
(
value
))
{
this
.
_onDidChangeList
.
fire
({
originalValue
:
item
.
value
,
value
:
value
,
sibling
:
siblingInput
&&
siblingInput
.
value
.
trim
(),
removeIndex
:
value
===
''
?
idx
:
undefined
targetIndex
:
idx
});
}
this
.
renderList
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录