Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
76f80ab0
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,发现更多精彩内容 >>
提交
76f80ab0
编写于
12月 21, 2016
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#17646 Refactoring settings model to make it easy for search
上级
0a20ce4d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
63 addition
and
70 deletion
+63
-70
src/vs/workbench/parts/preferences/browser/preferencesEditor.ts
.../workbench/parts/preferences/browser/preferencesEditor.ts
+4
-4
src/vs/workbench/parts/preferences/common/preferences.ts
src/vs/workbench/parts/preferences/common/preferences.ts
+4
-4
src/vs/workbench/parts/preferences/common/preferencesModels.ts
...s/workbench/parts/preferences/common/preferencesModels.ts
+55
-62
未找到文件。
src/vs/workbench/parts/preferences/browser/preferencesEditor.ts
浏览文件 @
76f80ab0
...
...
@@ -685,9 +685,9 @@ export class FilteredMatchesRenderer extends Disposable implements HiddenAreasPr
});
}
else
{
for
(
const
section
of
group
.
sections
)
{
if
(
section
.
description
Range
)
{
if
(
!
this
.
containsLine
(
section
.
description
Range
.
startLineNumber
,
filteredGroup
))
{
notMatchesRanges
.
push
(
this
.
createCompleteRange
(
section
.
description
Range
,
model
));
if
(
section
.
title
Range
)
{
if
(
!
this
.
containsLine
(
section
.
title
Range
.
startLineNumber
,
filteredGroup
))
{
notMatchesRanges
.
push
(
this
.
createCompleteRange
(
section
.
title
Range
,
model
));
}
}
for
(
const
setting
of
section
.
settings
)
{
...
...
@@ -707,7 +707,7 @@ export class FilteredMatchesRenderer extends Disposable implements HiddenAreasPr
}
for
(
const
section
of
settingsGroup
.
sections
)
{
if
(
section
.
descriptionRange
&&
lineNumber
>=
section
.
descriptionRange
.
startLineNumber
&&
lineNumber
<=
section
.
description
Range
.
endLineNumber
)
{
if
(
section
.
titleRange
&&
lineNumber
>=
section
.
titleRange
.
startLineNumber
&&
lineNumber
<=
section
.
title
Range
.
endLineNumber
)
{
return
true
;
}
...
...
src/vs/workbench/parts/preferences/common/preferences.ts
浏览文件 @
76f80ab0
...
...
@@ -19,8 +19,8 @@ export interface ISettingsGroup {
}
export
interface
ISettingsSection
{
description
Range
?:
IRange
;
description
?:
string
;
title
Range
?:
IRange
;
title
?:
string
;
settings
:
ISetting
[];
}
...
...
@@ -30,8 +30,8 @@ export interface ISetting {
keyRange
:
IRange
;
value
:
any
;
valueRange
:
IRange
;
description
:
string
;
descriptionRange
:
IRange
;
description
:
string
[]
;
descriptionRange
s
:
IRange
[]
;
}
export
interface
IFilterResult
{
...
...
src/vs/workbench/parts/preferences/common/preferencesModels.ts
浏览文件 @
76f80ab0
...
...
@@ -16,11 +16,11 @@ import { IConfigurationNode, IConfigurationRegistry, Extensions } from 'vs/platf
import
{
ISettingsEditorModel
,
IKeybindingsEditorModel
,
ISettingsGroup
,
ISetting
,
IFilterResult
,
ISettingsSection
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
ConfigurationTarget
}
from
'
vs/workbench/services/configuration/common/configurationEditing
'
;
import
{
IFilter
,
IMatch
,
or
,
matchesContiguousSubString
,
matchesPrefix
,
matchesFuzzy
,
matchesWords
}
from
'
vs/base/common/filters
'
;
import
{
IFilter
,
or
,
matchesContiguousSubString
,
matchesPrefix
,
/*matchesFuzzy,*/
matchesWords
}
from
'
vs/base/common/filters
'
;
export
abstract
class
AbstractSettingsModel
extends
Disposable
{
static
_
fuzzyFilter
:
IFilter
=
or
(
matchesPrefix
,
matchesContiguousSubString
,
matchesWords
,
matchesFuzzy
)
;
static
_
descriptionFilter
:
IFilter
=
matchesWords
;
public
get
groupsTerms
():
string
[]
{
return
this
.
settingsGroups
.
map
(
group
=>
'
@
'
+
group
.
id
);
...
...
@@ -53,7 +53,7 @@ export abstract class AbstractSettingsModel extends Disposable {
for
(
const
section
of
group
.
sections
)
{
const
settings
:
ISetting
[]
=
[];
for
(
const
setting
of
section
.
settings
)
{
const
settingMatches
=
this
.
_findMatchesInSetting
(
filter
,
regex
,
setting
);
const
settingMatches
=
this
.
_findMatchesInSetting
(
filter
,
setting
);
if
(
groupMatched
||
settingMatches
.
length
>
0
)
{
settings
.
push
(
setting
);
}
...
...
@@ -61,9 +61,9 @@ export abstract class AbstractSettingsModel extends Disposable {
}
if
(
settings
.
length
)
{
sections
.
push
({
description
:
section
.
description
,
title
:
section
.
title
,
settings
,
descriptionRange
:
section
.
description
Range
titleRange
:
section
.
title
Range
});
}
}
...
...
@@ -101,7 +101,38 @@ export abstract class AbstractSettingsModel extends Disposable {
return
null
;
}
protected
abstract
_findMatchesInSetting
(
searchString
:
string
,
searchRegex
:
RegExp
,
setting
:
ISetting
):
IRange
[];
private
_findMatchesInSetting
(
searchString
:
string
,
setting
:
ISetting
):
IRange
[]
{
const
result
:
IRange
[]
=
[...
this
.
_findMatchesInDescription
(
searchString
,
setting
)];
result
.
push
(...
this
.
_findMatchesInSettingKey
(
searchString
,
setting
));
return
result
;
}
private
_findMatchesInDescription
(
searchString
:
string
,
setting
:
ISetting
):
IRange
[]
{
const
result
:
IRange
[]
=
[];
for
(
var
i
=
0
;
i
<
setting
.
description
.
length
;
i
++
)
{
var
line
=
setting
.
description
[
i
];
const
matches
=
matchesContiguousSubString
(
searchString
,
line
)
||
[];
result
.
push
(...
matches
.
map
(
match
=>
<
IRange
>
{
startLineNumber
:
setting
.
descriptionRanges
[
i
].
startLineNumber
+
i
,
startColumn
:
setting
.
descriptionRanges
[
i
].
startColumn
+
match
.
start
,
endLineNumber
:
setting
.
descriptionRanges
[
i
].
startLineNumber
+
i
,
endColumn
:
setting
.
descriptionRanges
[
i
].
startColumn
+
match
.
end
}));
}
return
result
;
}
private
_findMatchesInSettingKey
(
searchString
:
string
,
setting
:
ISetting
):
IRange
[]
{
const
matches
=
or
(
matchesPrefix
,
matchesContiguousSubString
,
matchesWords
)(
searchString
,
setting
.
key
)
||
[];
return
matches
.
map
(
match
=>
<
IRange
>
{
startLineNumber
:
setting
.
keyRange
.
startLineNumber
,
startColumn
:
setting
.
keyRange
.
startColumn
+
match
.
start
,
endLineNumber
:
setting
.
keyRange
.
startLineNumber
,
endColumn
:
setting
.
keyRange
.
startColumn
+
match
.
end
});
}
public
abstract
settingsGroups
:
ISettingsGroup
[];
}
...
...
@@ -196,7 +227,7 @@ export class SettingsEditorModel extends AbstractSettingsModel implements ISetti
// setting started
let
settingStartPosition
=
model
.
getPositionAt
(
offset
);
settings
.
push
({
description
:
''
,
description
:
[]
,
key
:
name
,
keyRange
:
{
startLineNumber
:
settingStartPosition
.
lineNumber
,
...
...
@@ -212,7 +243,7 @@ export class SettingsEditorModel extends AbstractSettingsModel implements ISetti
},
value
:
null
,
valueRange
:
null
,
descriptionRange
:
null
,
descriptionRange
s
:
null
,
});
}
},
...
...
@@ -279,20 +310,6 @@ export class SettingsEditorModel extends AbstractSettingsModel implements ISetti
range
}]
:
[];
}
protected
_findMatchesInSetting
(
searchString
:
string
,
searchRegex
:
RegExp
,
setting
:
ISetting
):
IRange
[]
{
const
result
:
IRange
[]
=
[];
for
(
let
lineNumber
=
setting
.
range
.
startLineNumber
;
lineNumber
<=
setting
.
range
.
endLineNumber
;
lineNumber
++
)
{
result
.
push
(...
this
.
_findMatchesInLine
(
searchString
,
lineNumber
));
}
return
result
;
}
private
_findMatchesInLine
(
searchString
:
string
,
lineNumber
:
number
):
IRange
[]
{
return
this
.
model
.
findMatches
(
searchString
,
{
startLineNumber
:
lineNumber
,
startColumn
:
this
.
model
.
getLineMinColumn
(
lineNumber
),
endLineNumber
:
lineNumber
,
endColumn
:
this
.
model
.
getLineMaxColumn
(
lineNumber
),
},
false
,
false
,
false
);
}
}
export
class
DefaultSettingsEditorModel
extends
AbstractSettingsModel
implements
ISettingsEditorModel
{
...
...
@@ -400,7 +417,7 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
result
.
push
(
settingsGroup
);
}
}
else
{
settingsGroup
.
sections
[
settingsGroup
.
sections
.
length
-
1
].
description
=
config
.
title
;
settingsGroup
.
sections
[
settingsGroup
.
sections
.
length
-
1
].
title
=
config
.
title
;
}
}
if
(
config
.
properties
)
{
...
...
@@ -411,8 +428,8 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
const
configurationSettings
:
ISetting
[]
=
Object
.
keys
(
config
.
properties
).
map
((
key
)
=>
{
const
prop
=
config
.
properties
[
key
];
const
value
=
prop
.
default
;
const
description
=
prop
.
description
||
''
;
return
{
key
,
value
,
description
,
range
:
null
,
keyRange
:
null
,
valueRange
:
null
,
descriptionRange
:
null
};
const
description
=
(
prop
.
description
||
''
).
split
(
'
\n
'
)
;
return
{
key
,
value
,
description
,
range
:
null
,
keyRange
:
null
,
valueRange
:
null
,
descriptionRange
s
:
[]
};
});
settingsGroup
.
sections
[
settingsGroup
.
sections
.
length
-
1
].
settings
.
push
(...
configurationSettings
);
}
...
...
@@ -466,16 +483,20 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
this
.
_contentByLines
.
push
(
''
);
let
groupStart
=
this
.
_contentByLines
.
length
+
1
;
for
(
const
section
of
group
.
sections
)
{
if
(
section
.
description
)
{
if
(
section
.
title
)
{
let
sectionTitleStart
=
this
.
_contentByLines
.
length
+
1
;
this
.
addDescription
(
section
.
description
,
this
.
indent
,
this
.
_contentByLines
);
section
.
description
Range
=
{
startLineNumber
:
sectionTitleStart
,
startColumn
:
1
,
endLineNumber
:
this
.
_contentByLines
.
length
,
endColumn
:
this
.
_contentByLines
[
this
.
_contentByLines
.
length
-
1
].
length
};
this
.
addDescription
(
[
section
.
title
]
,
this
.
indent
,
this
.
_contentByLines
);
section
.
title
Range
=
{
startLineNumber
:
sectionTitleStart
,
startColumn
:
1
,
endLineNumber
:
this
.
_contentByLines
.
length
,
endColumn
:
this
.
_contentByLines
[
this
.
_contentByLines
.
length
-
1
].
length
};
}
for
(
const
setting
of
section
.
settings
)
{
const
settingStart
=
this
.
_contentByLines
.
length
+
1
;
this
.
addDescription
(
setting
.
description
,
this
.
indent
,
this
.
_contentByLines
);
setting
.
descriptionRange
=
{
startLineNumber
:
settingStart
,
startColumn
:
1
,
endLineNumber
:
this
.
_contentByLines
.
length
,
endColumn
:
this
.
_contentByLines
[
this
.
_contentByLines
.
length
-
1
].
length
};
setting
.
descriptionRanges
=
[];
const
descriptionPreValue
=
this
.
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
;
const
keyString
=
JSON
.
stringify
(
setting
.
key
);
...
...
@@ -506,41 +527,13 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
return
lastSetting
;
}
private
addDescription
(
description
:
string
,
indent
:
string
,
result
:
string
[])
{
const
multiLines
=
description
.
split
(
'
\n
'
);
for
(
const
line
of
multiLines
)
{
private
addDescription
(
description
:
string
[],
indent
:
string
,
result
:
string
[])
{
for
(
const
line
of
description
)
{
result
.
push
(
indent
+
'
//
'
+
line
);
}
}
protected
_findMatchesInSetting
(
searchString
:
string
,
searchRegex
:
RegExp
,
setting
:
ISetting
):
IRange
[]
{
const
result
:
IRange
[]
=
[...
this
.
_findMatchesInDescription
(
searchString
,
setting
)];
for
(
let
lineNumber
=
setting
.
valueRange
.
startLineNumber
;
lineNumber
<=
setting
.
valueRange
.
endLineNumber
;
lineNumber
++
)
{
result
.
push
(...
this
.
_findMatchesInLine
(
searchRegex
,
lineNumber
));
}
return
result
;
}
private
_findMatchesInDescription
(
searchString
:
string
,
setting
:
ISetting
):
IRange
[]
{
const
result
:
IRange
[]
=
[];
for
(
let
lineNumber
=
setting
.
descriptionRange
.
startLineNumber
;
lineNumber
<=
setting
.
descriptionRange
.
endLineNumber
;
lineNumber
++
)
{
const
content
=
this
.
_contentByLines
[
lineNumber
-
1
];
const
matches
:
IMatch
[]
=
AbstractSettingsModel
.
_fuzzyFilter
(
searchString
,
content
);
if
(
matches
)
{
result
.
push
(...
matches
.
map
(
match
=>
{
return
<
IRange
>
{
startLineNumber
:
lineNumber
,
startColumn
:
match
.
start
+
1
,
endLineNumber
:
lineNumber
,
endColumn
:
match
.
end
+
1
};
}));
}
}
return
result
;
}
private
_findMatchesInLine
(
searchRegex
:
RegExp
,
lineNumber
:
number
):
IRange
[]
{
/*private _findMatchesInLine(searchRegex: RegExp, lineNumber: number): IRange[] {
const result: IRange[] = [];
const text = this._contentByLines[lineNumber - 1];
var m: RegExpExecArray;
...
...
@@ -558,7 +551,7 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
}
} while (m);
return result;
}
}
*/
}
export
class
DefaultKeybindingsEditorModel
implements
IKeybindingsEditorModel
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录