Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
5e72eec2
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,发现更多精彩内容 >>
提交
5e72eec2
编写于
3月 17, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#22282 Support searching in override settings
上级
9d2e0611
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
78 addition
and
41 deletion
+78
-41
src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts
...rkbench/parts/preferences/browser/preferencesRenderers.ts
+1
-1
src/vs/workbench/parts/preferences/common/preferencesModels.ts
...s/workbench/parts/preferences/common/preferencesModels.ts
+77
-40
未找到文件。
src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts
浏览文件 @
5e72eec2
...
...
@@ -748,7 +748,7 @@ class EditSettingRenderer extends Disposable {
break
;
}
if
(
lineNumber
>=
setting
.
range
.
startLineNumber
&&
lineNumber
<=
setting
.
range
.
endLineNumber
)
{
if
(
setting
.
overrides
.
length
>
0
)
{
if
(
!
this
.
isDefaultSettings
()
&&
setting
.
overrides
.
length
)
{
// Only one level because override settings cannot have override settings
for
(
const
overrideSetting
of
setting
.
overrides
)
{
if
(
lineNumber
>=
overrideSetting
.
range
.
startLineNumber
&&
lineNumber
<=
overrideSetting
.
range
.
endLineNumber
)
{
...
...
src/vs/workbench/parts/preferences/common/preferencesModels.ts
浏览文件 @
5e72eec2
...
...
@@ -103,6 +103,16 @@ export abstract class AbstractSettingsModel extends EditorModel {
}
private
_findMatchesInSetting
(
searchString
:
string
,
setting
:
ISetting
):
IRange
[]
{
const
result
=
this
.
_doFindMatchesInSetting
(
searchString
,
setting
);
if
(
setting
.
overrides
&&
setting
.
overrides
.
length
)
{
for
(
const
subSetting
of
setting
.
overrides
)
{
result
.
push
(...
this
.
_findMatchesInSetting
(
searchString
,
subSetting
));
}
}
return
result
;
}
private
_doFindMatchesInSetting
(
searchString
:
string
,
setting
:
ISetting
):
IRange
[]
{
const
registry
:
{
[
qualifiedKey
:
string
]:
IJSONSchema
}
=
Registry
.
as
<
IConfigurationRegistry
>
(
Extensions
.
Configuration
).
getConfigurationProperties
();
const
schema
:
IJSONSchema
=
registry
[
setting
.
key
];
...
...
@@ -404,15 +414,12 @@ export class SettingsEditorModel extends AbstractSettingsModel implements ISetti
export
class
DefaultSettingsEditorModel
extends
AbstractSettingsModel
implements
ISettingsEditorModel
{
private
indent
:
string
;
private
_allSettingsGroups
:
ISettingsGroup
[];
private
_content
:
string
;
private
_contentByLines
:
string
[];
constructor
(
private
_uri
:
URI
,
private
_mostCommonlyUsedSettingsKeys
:
string
[])
{
super
();
this
.
indent
=
'
'
;
}
public
get
uri
():
URI
{
...
...
@@ -523,12 +530,7 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
settingsGroup
=
{
sections
:
[{
settings
:
[]
}],
id
:
config
.
id
,
title
:
config
.
id
,
titleRange
:
null
,
range
:
null
};
result
.
push
(
settingsGroup
);
}
const
configurationSettings
:
ISetting
[]
=
Object
.
keys
(
config
.
properties
).
map
((
key
)
=>
{
const
prop
=
config
.
properties
[
key
];
const
value
=
prop
.
default
;
const
description
=
(
prop
.
description
||
''
).
split
(
'
\n
'
);
return
{
key
,
value
,
description
,
range
:
null
,
keyRange
:
null
,
valueRange
:
null
,
descriptionRanges
:
[],
overrides
:
[]
};
});
const
configurationSettings
:
ISetting
[]
=
this
.
parseSettings
(
config
.
properties
);
settingsGroup
.
sections
[
settingsGroup
.
sections
.
length
-
1
].
settings
.
push
(...
configurationSettings
);
}
if
(
config
.
allOf
)
{
...
...
@@ -537,6 +539,20 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
return
result
;
}
private
parseSettings
(
settingsObject
:
any
):
ISetting
[]
{
return
Object
.
keys
(
settingsObject
).
map
((
key
)
=>
{
const
prop
=
settingsObject
[
key
];
const
value
=
prop
.
default
;
const
description
=
(
prop
.
description
||
''
).
split
(
'
\n
'
);
const
overrides
=
OVERRIDE_PROPERTY_PATTERN
.
test
(
key
)
?
this
.
parseOverrideSettings
(
prop
.
default
)
:
[];
return
{
key
,
value
,
description
,
range
:
null
,
keyRange
:
null
,
valueRange
:
null
,
descriptionRanges
:
[],
overrides
};
});
}
private
parseOverrideSettings
(
overrideSettings
:
any
):
ISetting
[]
{
return
Object
.
keys
(
overrideSettings
).
map
((
key
)
=>
({
key
,
value
:
overrideSettings
[
key
],
description
:
[],
range
:
null
,
keyRange
:
null
,
valueRange
:
null
,
descriptionRanges
:
[],
overrides
:
[]
}));
}
private
compareConfigurationNodes
(
c1
:
IConfigurationNode
,
c2
:
IConfigurationNode
):
number
{
if
(
typeof
c1
.
order
!==
'
number
'
)
{
return
1
;
...
...
@@ -577,52 +593,73 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
}
private
pushGroup
(
group
:
ISettingsGroup
):
ISetting
{
const
indent
=
'
'
;
let
lastSetting
:
ISetting
=
null
;
this
.
_contentByLines
.
push
(
''
);
let
groupStart
=
this
.
_contentByLines
.
length
+
1
;
for
(
const
section
of
group
.
sections
)
{
if
(
section
.
title
)
{
let
sectionTitleStart
=
this
.
_contentByLines
.
length
+
1
;
this
.
addDescription
([
section
.
title
],
this
.
indent
,
this
.
_contentByLines
);
this
.
addDescription
([
section
.
title
],
indent
,
this
.
_contentByLines
);
section
.
titleRange
=
{
startLineNumber
:
sectionTitleStart
,
startColumn
:
1
,
endLineNumber
:
this
.
_contentByLines
.
length
,
endColumn
:
this
.
_contentByLines
[
this
.
_contentByLines
.
length
-
1
].
length
};
}
for
(
const
setting
of
section
.
settings
)
{
this
.
pushSetting
(
setting
,
indent
);
lastSetting
=
setting
;
}
}
group
.
range
=
{
startLineNumber
:
groupStart
,
startColumn
:
1
,
endLineNumber
:
this
.
_contentByLines
.
length
,
endColumn
:
this
.
_contentByLines
[
this
.
_contentByLines
.
length
-
1
].
length
};
return
lastSetting
;
}
private
pushSetting
(
setting
:
ISetting
,
indent
:
string
):
void
{
const
settingStart
=
this
.
_contentByLines
.
length
+
1
;
setting
.
descriptionRanges
=
[];
const
descriptionPreValue
=
this
.
indent
+
'
//
'
;
const
descriptionPreValue
=
indent
+
'
//
'
;
for
(
const
line
of
setting
.
description
)
{
this
.
_contentByLines
.
push
(
descriptionPreValue
+
line
);
setting
.
descriptionRanges
.
push
({
startLineNumber
:
this
.
_contentByLines
.
length
,
startColumn
:
this
.
_contentByLines
[
this
.
_contentByLines
.
length
-
1
].
indexOf
(
line
)
+
1
,
endLineNumber
:
this
.
_contentByLines
.
length
,
endColumn
:
this
.
_contentByLines
[
this
.
_contentByLines
.
length
-
1
].
length
});
}
let
preValueConent
=
this
.
indent
;
let
preValueConent
=
indent
;
const
keyString
=
JSON
.
stringify
(
setting
.
key
);
preValueConent
+=
keyString
;
setting
.
keyRange
=
{
startLineNumber
:
this
.
_contentByLines
.
length
+
1
,
startColumn
:
preValueConent
.
indexOf
(
setting
.
key
)
+
1
,
endLineNumber
:
this
.
_contentByLines
.
length
+
1
,
endColumn
:
setting
.
key
.
length
};
preValueConent
+=
'
:
'
;
const
valueStart
=
this
.
_contentByLines
.
length
+
1
;
let
valueString
=
JSON
.
stringify
(
setting
.
value
,
null
,
this
.
indent
);
this
.
pushValue
(
setting
,
preValueConent
,
indent
);
setting
.
valueRange
=
{
startLineNumber
:
valueStart
,
startColumn
:
preValueConent
.
length
+
1
,
endLineNumber
:
this
.
_contentByLines
.
length
,
endColumn
:
this
.
_contentByLines
[
this
.
_contentByLines
.
length
-
1
].
length
+
1
};
this
.
_contentByLines
[
this
.
_contentByLines
.
length
-
1
]
+=
'
,
'
;
this
.
_contentByLines
.
push
(
''
);
setting
.
range
=
{
startLineNumber
:
settingStart
,
startColumn
:
1
,
endLineNumber
:
this
.
_contentByLines
.
length
,
endColumn
:
this
.
_contentByLines
[
this
.
_contentByLines
.
length
-
1
].
length
};
}
private
pushValue
(
setting
:
ISetting
,
preValueConent
:
string
,
indent
:
string
):
void
{
let
valueString
=
JSON
.
stringify
(
setting
.
value
,
null
,
indent
);
if
(
valueString
&&
(
typeof
setting
.
value
===
'
object
'
))
{
if
(
setting
.
overrides
.
length
)
{
this
.
_contentByLines
.
push
(
preValueConent
+
'
{
'
);
for
(
const
subSetting
of
setting
.
overrides
)
{
this
.
pushSetting
(
subSetting
,
indent
+
indent
);
this
.
_contentByLines
.
pop
();
}
const
lastSetting
=
setting
.
overrides
[
setting
.
overrides
.
length
-
1
];
const
content
=
this
.
_contentByLines
[
lastSetting
.
range
.
endLineNumber
-
2
];
this
.
_contentByLines
[
lastSetting
.
range
.
endLineNumber
-
2
]
=
content
.
substring
(
0
,
content
.
length
-
1
);
this
.
_contentByLines
.
push
(
indent
+
'
}
'
);
}
else
{
const
mulitLineValue
=
valueString
.
split
(
'
\n
'
);
this
.
_contentByLines
.
push
(
preValueConent
+
mulitLineValue
[
0
]);
for
(
let
i
=
1
;
i
<
mulitLineValue
.
length
;
i
++
)
{
this
.
_contentByLines
.
push
(
this
.
indent
+
mulitLineValue
[
i
]);
this
.
_contentByLines
.
push
(
indent
+
mulitLineValue
[
i
]);
}
}
}
else
{
this
.
_contentByLines
.
push
(
preValueConent
+
valueString
);
}
setting
.
valueRange
=
{
startLineNumber
:
valueStart
,
startColumn
:
preValueConent
.
length
+
1
,
endLineNumber
:
this
.
_contentByLines
.
length
,
endColumn
:
this
.
_contentByLines
[
this
.
_contentByLines
.
length
-
1
].
length
+
1
};
this
.
_contentByLines
[
this
.
_contentByLines
.
length
-
1
]
+=
'
,
'
;
lastSetting
=
setting
;
this
.
_contentByLines
.
push
(
''
);
setting
.
range
=
{
startLineNumber
:
settingStart
,
startColumn
:
1
,
endLineNumber
:
this
.
_contentByLines
.
length
,
endColumn
:
this
.
_contentByLines
[
this
.
_contentByLines
.
length
-
1
].
length
};
}
}
group
.
range
=
{
startLineNumber
:
groupStart
,
startColumn
:
1
,
endLineNumber
:
this
.
_contentByLines
.
length
,
endColumn
:
this
.
_contentByLines
[
this
.
_contentByLines
.
length
-
1
].
length
};
return
lastSetting
;
}
private
addDescription
(
description
:
string
[],
indent
:
string
,
result
:
string
[])
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录