Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
6527ca29
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,发现更多精彩内容 >>
提交
6527ca29
编写于
4月 23, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #48282 - increase size of search history buffer and add "Clear search history" command
上级
e0a44567
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
87 addition
and
35 deletion
+87
-35
src/vs/base/common/history.ts
src/vs/base/common/history.ts
+5
-0
src/vs/base/test/common/history.test.ts
src/vs/base/test/common/history.test.ts
+31
-24
src/vs/workbench/parts/search/browser/patternInputWidget.ts
src/vs/workbench/parts/search/browser/patternInputWidget.ts
+5
-3
src/vs/workbench/parts/search/browser/searchActions.ts
src/vs/workbench/parts/search/browser/searchActions.ts
+9
-1
src/vs/workbench/parts/search/browser/searchView.ts
src/vs/workbench/parts/search/browser/searchView.ts
+16
-5
src/vs/workbench/parts/search/browser/searchWidget.ts
src/vs/workbench/parts/search/browser/searchWidget.ts
+6
-1
src/vs/workbench/parts/search/common/constants.ts
src/vs/workbench/parts/search/common/constants.ts
+1
-0
src/vs/workbench/parts/search/electron-browser/search.contribution.ts
...ench/parts/search/electron-browser/search.contribution.ts
+14
-1
未找到文件。
src/vs/base/common/history.ts
浏览文件 @
6527ca29
...
...
@@ -65,6 +65,11 @@ export class HistoryNavigator<T> implements INavigator<T> {
return
this
.
_navigator
.
last
();
}
public
clear
():
void
{
this
.
_initialize
([]);
this
.
_onChange
();
}
private
_onChange
()
{
this
.
_reduceToLimit
();
this
.
_navigator
=
new
ArrayNavigator
(
this
.
_elements
);
...
...
src/vs/base/test/common/history.test.ts
浏览文件 @
6527ca29
...
...
@@ -9,36 +9,36 @@ import { HistoryNavigator } from 'vs/base/common/history';
suite
(
'
History Navigator
'
,
()
=>
{
test
(
'
create reduces the input to limit
'
,
function
()
{
le
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
2
);
test
(
'
create reduces the input to limit
'
,
()
=>
{
cons
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
2
);
assert
.
deepEqual
([
'
3
'
,
'
4
'
],
toArray
(
testObject
));
});
test
(
'
create sets the position to last
'
,
function
()
{
le
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
test
(
'
create sets the position to last
'
,
()
=>
{
cons
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
assert
.
equal
(
'
4
'
,
testObject
.
current
());
assert
.
equal
(
null
,
testObject
.
next
());
assert
.
equal
(
'
3
'
,
testObject
.
previous
());
});
test
(
'
last returns last element
'
,
function
()
{
le
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
test
(
'
last returns last element
'
,
()
=>
{
cons
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
testObject
.
first
();
assert
.
equal
(
'
4
'
,
testObject
.
last
());
});
test
(
'
first returns first element
'
,
function
()
{
le
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
test
(
'
first returns first element
'
,
()
=>
{
cons
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
assert
.
equal
(
'
2
'
,
testObject
.
first
());
});
test
(
'
next returns next element
'
,
function
()
{
le
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
test
(
'
next returns next element
'
,
()
=>
{
cons
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
testObject
.
first
();
...
...
@@ -47,16 +47,16 @@ suite('History Navigator', () => {
assert
.
equal
(
null
,
testObject
.
next
());
});
test
(
'
previous returns previous element
'
,
function
()
{
le
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
test
(
'
previous returns previous element
'
,
()
=>
{
cons
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
assert
.
equal
(
'
3
'
,
testObject
.
previous
());
assert
.
equal
(
'
2
'
,
testObject
.
previous
());
assert
.
equal
(
null
,
testObject
.
previous
());
});
test
(
'
next on last element returs null and remains on last
'
,
function
()
{
le
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
test
(
'
next on last element returs null and remains on last
'
,
()
=>
{
cons
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
testObject
.
first
();
testObject
.
last
();
...
...
@@ -65,8 +65,8 @@ suite('History Navigator', () => {
assert
.
equal
(
null
,
testObject
.
next
());
});
test
(
'
previous on first element returs null and remains on first
'
,
function
()
{
le
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
test
(
'
previous on first element returs null and remains on first
'
,
()
=>
{
cons
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
testObject
.
first
();
...
...
@@ -74,24 +74,24 @@ suite('History Navigator', () => {
assert
.
equal
(
null
,
testObject
.
previous
());
});
test
(
'
add reduces the input to limit
'
,
function
()
{
le
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
2
);
test
(
'
add reduces the input to limit
'
,
()
=>
{
cons
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
2
);
testObject
.
add
(
'
5
'
);
assert
.
deepEqual
([
'
4
'
,
'
5
'
],
toArray
(
testObject
));
});
test
(
'
adding existing element changes the position
'
,
function
()
{
le
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
5
);
test
(
'
adding existing element changes the position
'
,
()
=>
{
cons
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
5
);
testObject
.
add
(
'
2
'
);
assert
.
deepEqual
([
'
1
'
,
'
3
'
,
'
4
'
,
'
2
'
],
toArray
(
testObject
));
});
test
(
'
add resets the navigator to last
'
,
function
()
{
le
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
test
(
'
add resets the navigator to last
'
,
()
=>
{
cons
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
,
'
4
'
],
3
);
testObject
.
first
();
testObject
.
add
(
'
5
'
);
...
...
@@ -100,14 +100,21 @@ suite('History Navigator', () => {
assert
.
equal
(
null
,
testObject
.
next
());
});
test
(
'
adding an existing item changes the order
'
,
function
()
{
le
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
]);
test
(
'
adding an existing item changes the order
'
,
()
=>
{
cons
t
testObject
=
new
HistoryNavigator
([
'
1
'
,
'
2
'
,
'
3
'
]);
testObject
.
add
(
'
1
'
);
assert
.
deepEqual
([
'
2
'
,
'
3
'
,
'
1
'
],
toArray
(
testObject
));
});
test
(
'
clear
'
,
()
=>
{
const
testObject
=
new
HistoryNavigator
([
'
a
'
,
'
b
'
,
'
c
'
]);
assert
.
equal
(
'
c
'
,
testObject
.
current
());
testObject
.
clear
();
assert
.
equal
(
undefined
,
testObject
.
current
());
});
function
toArray
(
historyNavigator
:
HistoryNavigator
<
string
>
):
string
[]
{
let
result
=
[];
historyNavigator
.
first
();
...
...
src/vs/workbench/parts/search/browser/patternInputWidget.ts
浏览文件 @
6527ca29
...
...
@@ -21,6 +21,8 @@ export interface IOptions {
width
?:
number
;
validation
?:
IInputValidator
;
ariaLabel
?:
string
;
history
?:
string
[];
historyLimit
?:
number
;
}
export
class
PatternInputWidget
extends
Widget
{
...
...
@@ -47,7 +49,7 @@ export class PatternInputWidget extends Widget {
constructor
(
parent
:
HTMLElement
,
private
contextViewProvider
:
IContextViewProvider
,
protected
themeService
:
IThemeService
,
options
:
IOptions
=
Object
.
create
(
null
))
{
super
();
this
.
history
=
new
HistoryNavigator
<
string
>
();
this
.
history
=
new
HistoryNavigator
<
string
>
(
options
.
history
||
[],
options
.
historyLimit
);
this
.
onOptionChange
=
null
;
this
.
width
=
options
.
width
||
100
;
this
.
placeholder
=
options
.
placeholder
||
''
;
...
...
@@ -123,8 +125,8 @@ export class PatternInputWidget extends Widget {
return
this
.
history
.
getHistory
();
}
public
setHistory
(
history
:
string
[])
{
this
.
history
=
new
HistoryNavigator
<
string
>
(
history
);
public
clearHistory
():
void
{
this
.
history
.
clear
(
);
}
public
onSearchSubmit
():
void
{
...
...
src/vs/workbench/parts/search/browser/searchActions.ts
浏览文件 @
6527ca29
...
...
@@ -750,7 +750,7 @@ function allFolderMatchesToString(folderMatches: FolderMatch[], maxMatches: numb
return
folderResults
.
join
(
lineDelimiter
+
lineDelimiter
);
}
export
const
copyAllCommand
:
ICommandHandler
=
(
accessor
)
=>
{
export
const
copyAllCommand
:
ICommandHandler
=
accessor
=>
{
const
viewletService
=
accessor
.
get
(
IViewletService
);
const
panelService
=
accessor
.
get
(
IPanelService
);
const
clipboardService
=
accessor
.
get
(
IClipboardService
);
...
...
@@ -761,3 +761,11 @@ export const copyAllCommand: ICommandHandler = (accessor) => {
const
text
=
allFolderMatchesToString
(
root
.
folderMatches
(),
maxClipboardMatches
);
clipboardService
.
writeText
(
text
);
};
export
const
clearHistoryCommand
:
ICommandHandler
=
accessor
=>
{
const
viewletService
=
accessor
.
get
(
IViewletService
);
const
panelService
=
accessor
.
get
(
IPanelService
);
const
searchView
=
getSearchView
(
viewletService
,
panelService
);
searchView
.
clearHistory
();
};
src/vs/workbench/parts/search/browser/searchView.ts
浏览文件 @
6527ca29
...
...
@@ -65,6 +65,8 @@ import { IPartService } from 'vs/workbench/services/part/common/partService';
export
class
SearchView
extends
Viewlet
implements
IViewlet
,
IPanel
{
private
static
readonly
MAX_HISTORY_ITEMS
=
100
;
private
static
readonly
MAX_TEXT_RESULTS
=
10000
;
private
static
readonly
SHOW_REPLACE_STORAGE_KEY
=
'
vs.search.show.replace
'
;
...
...
@@ -240,11 +242,12 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
builder
.
element
(
'
h4
'
,
{
text
:
title
});
this
.
inputPatternIncludes
=
new
PatternInputWidget
(
builder
.
getContainer
(),
this
.
contextViewService
,
this
.
themeService
,
{
ariaLabel
:
nls
.
localize
(
'
label.includes
'
,
'
Search Include Patterns
'
)
ariaLabel
:
nls
.
localize
(
'
label.includes
'
,
'
Search Include Patterns
'
),
history
:
patternIncludesHistory
,
historyLimit
:
SearchView
.
MAX_HISTORY_ITEMS
});
this
.
inputPatternIncludes
.
setValue
(
patternIncludes
);
this
.
inputPatternIncludes
.
setHistory
(
patternIncludesHistory
);
this
.
inputPatternIncludes
.
on
(
FindInput
.
OPTION_CHANGE
,
(
e
)
=>
{
...
...
@@ -262,12 +265,13 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
builder
.
element
(
'
h4
'
,
{
text
:
title
});
this
.
inputPatternExcludes
=
new
ExcludePatternInputWidget
(
builder
.
getContainer
(),
this
.
contextViewService
,
this
.
themeService
,
{
ariaLabel
:
nls
.
localize
(
'
label.excludes
'
,
'
Search Exclude Patterns
'
)
ariaLabel
:
nls
.
localize
(
'
label.excludes
'
,
'
Search Exclude Patterns
'
),
history
:
patternExclusionsHistory
,
historyLimit
:
SearchView
.
MAX_HISTORY_ITEMS
});
this
.
inputPatternExcludes
.
setValue
(
patternExclusions
);
this
.
inputPatternExcludes
.
setUseExcludesAndIgnoreFiles
(
useExcludesAndIgnoreFiles
);
this
.
inputPatternExcludes
.
setHistory
(
patternExclusionsHistory
);
this
.
inputPatternExcludes
.
on
(
FindInput
.
OPTION_CHANGE
,
(
e
)
=>
{
...
...
@@ -333,7 +337,8 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
isRegex
:
isRegex
,
isCaseSensitive
:
isCaseSensitive
,
isWholeWords
:
isWholeWords
,
history
:
searchHistory
history
:
searchHistory
,
historyLimit
:
SearchView
.
MAX_HISTORY_ITEMS
});
if
(
this
.
storageService
.
getBoolean
(
SearchView
.
SHOW_REPLACE_STORAGE_KEY
,
StorageScope
.
WORKSPACE
,
true
))
{
...
...
@@ -1500,6 +1505,12 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this
.
updateTitleArea
();
}
public
clearHistory
():
void
{
this
.
searchWidget
.
clearHistory
();
this
.
inputPatternExcludes
.
clearHistory
();
this
.
inputPatternIncludes
.
clearHistory
();
}
public
shutdown
():
void
{
const
isRegex
=
this
.
searchWidget
.
searchInput
.
getRegex
();
const
isWholeWords
=
this
.
searchWidget
.
searchInput
.
getWholeWords
();
...
...
src/vs/workbench/parts/search/browser/searchWidget.ts
浏览文件 @
6527ca29
...
...
@@ -39,6 +39,7 @@ export interface ISearchWidgetOptions {
isCaseSensitive
?:
boolean
;
isWholeWords
?:
boolean
;
history
?:
string
[];
historyLimit
?:
number
;
}
class
ReplaceAllAction
extends
Action
{
...
...
@@ -127,7 +128,7 @@ export class SearchWidget extends Widget {
@
IConfigurationService
private
configurationService
:
IConfigurationService
)
{
super
();
this
.
searchHistory
=
new
HistoryNavigator
<
string
>
(
options
.
history
);
this
.
searchHistory
=
new
HistoryNavigator
<
string
>
(
options
.
history
,
options
.
historyLimit
);
this
.
replaceActive
=
Constants
.
ReplaceActiveKey
.
bindTo
(
this
.
keyBindingService
);
this
.
searchInputBoxFocused
=
Constants
.
SearchInputBoxFocusedKey
.
bindTo
(
this
.
keyBindingService
);
this
.
replaceInputBoxFocused
=
Constants
.
ReplaceInputBoxFocusedKey
.
bindTo
(
this
.
keyBindingService
);
...
...
@@ -179,6 +180,10 @@ export class SearchWidget extends Widget {
return
this
.
searchHistory
.
getHistory
();
}
public
clearHistory
():
void
{
this
.
searchHistory
.
clear
();
}
public
showNextSearchTerm
()
{
let
next
=
this
.
searchHistory
.
next
();
if
(
next
)
{
...
...
src/vs/workbench/parts/search/common/constants.ts
浏览文件 @
6527ca29
...
...
@@ -15,6 +15,7 @@ export const RemoveActionId = 'search.action.remove';
export
const
CopyPathCommandId
=
'
search.action.copyPath
'
;
export
const
CopyMatchCommandId
=
'
search.action.copyMatch
'
;
export
const
CopyAllCommandId
=
'
search.action.copyAll
'
;
export
const
ClearSearchHistoryCommandId
=
'
search.action.clearHistory
'
;
export
const
ReplaceActionId
=
'
search.action.replace
'
;
export
const
ReplaceAllInFileActionId
=
'
search.action.replaceAllInFile
'
;
export
const
ReplaceAllInFolderActionId
=
'
search.action.replaceAllInFolder
'
;
...
...
src/vs/workbench/parts/search/electron-browser/search.contribution.ts
浏览文件 @
6527ca29
...
...
@@ -53,7 +53,7 @@ import { getMultiSelectedResources } from 'vs/workbench/parts/files/browser/file
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
PanelRegistry
,
Extensions
as
PanelExtensions
,
PanelDescriptor
}
from
'
vs/workbench/browser/panel
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
openSearchView
,
getSearchView
,
ReplaceAllInFolderAction
,
ReplaceAllAction
,
CloseReplaceAction
,
FocusNextInputAction
,
FocusPreviousInputAction
,
FocusNextSearchResultAction
,
FocusPreviousSearchResultAction
,
ReplaceInFilesAction
,
FindInFilesAction
,
FocusActiveEditorCommand
,
toggleCaseSensitiveCommand
,
ShowNextSearchTermAction
,
ShowPreviousSearchTermAction
,
toggleRegexCommand
,
ShowPreviousSearchIncludeAction
,
ShowNextSearchIncludeAction
,
CollapseDeepestExpandedLevelAction
,
toggleWholeWordCommand
,
RemoveAction
,
ReplaceAction
,
ClearSearchResultsAction
,
copyPathCommand
,
copyMatchCommand
,
copyAllCommand
,
ShowNextSearchExcludeAction
,
ShowPreviousSearchExcludeAction
}
from
'
vs/workbench/parts/search/browser/searchActions
'
;
import
{
openSearchView
,
getSearchView
,
ReplaceAllInFolderAction
,
ReplaceAllAction
,
CloseReplaceAction
,
FocusNextInputAction
,
FocusPreviousInputAction
,
FocusNextSearchResultAction
,
FocusPreviousSearchResultAction
,
ReplaceInFilesAction
,
FindInFilesAction
,
FocusActiveEditorCommand
,
toggleCaseSensitiveCommand
,
ShowNextSearchTermAction
,
ShowPreviousSearchTermAction
,
toggleRegexCommand
,
ShowPreviousSearchIncludeAction
,
ShowNextSearchIncludeAction
,
CollapseDeepestExpandedLevelAction
,
toggleWholeWordCommand
,
RemoveAction
,
ReplaceAction
,
ClearSearchResultsAction
,
copyPathCommand
,
copyMatchCommand
,
copyAllCommand
,
ShowNextSearchExcludeAction
,
ShowPreviousSearchExcludeAction
,
clearHistoryCommand
}
from
'
vs/workbench/parts/search/browser/searchActions
'
;
import
{
VIEW_ID
,
ISearchConfigurationProperties
}
from
'
vs/platform/search/common/search
'
;
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
import
{
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
...
...
@@ -291,6 +291,19 @@ CommandsRegistry.registerCommand({
handler
:
copyAllCommand
});
CommandsRegistry
.
registerCommand
({
id
:
Constants
.
ClearSearchHistoryCommandId
,
handler
:
clearHistoryCommand
});
const
clearSearchHistoryLabel
=
nls
.
localize
(
'
clearSearchHistoryLabel
'
,
"
Clear Search History
"
);
const
ClearSearchHistoryCommand
:
ICommandAction
=
{
id
:
Constants
.
ClearSearchHistoryCommandId
,
title
:
clearSearchHistoryLabel
,
category
};
MenuRegistry
.
addCommand
(
ClearSearchHistoryCommand
);
CommandsRegistry
.
registerCommand
({
id
:
Constants
.
ToggleSearchViewPositionCommandId
,
handler
:
(
accessor
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录