Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ebec7141
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,发现更多精彩内容 >>
提交
ebec7141
编写于
5月 05, 2020
作者:
J
Jackson Kearl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adopt registerAction2 in search editor land.
Ref #96672.
上级
86cb707a
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
100 addition
and
113 deletion
+100
-113
src/vs/workbench/contrib/searchEditor/browser/searchEditor.contribution.ts
...contrib/searchEditor/browser/searchEditor.contribution.ts
+98
-27
src/vs/workbench/contrib/searchEditor/browser/searchEditorActions.ts
...bench/contrib/searchEditor/browser/searchEditorActions.ts
+2
-86
未找到文件。
src/vs/workbench/contrib/searchEditor/browser/searchEditor.contribution.ts
浏览文件 @
ebec7141
...
...
@@ -10,7 +10,7 @@ import { URI } from 'vs/base/common/uri';
import
{
ServicesAccessor
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
ToggleCaseSensitiveKeybinding
,
ToggleRegexKeybinding
,
ToggleWholeWordKeybinding
}
from
'
vs/editor/contrib/find/findModel
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
MenuId
,
MenuRegistry
,
SyncActionDescriptor
}
from
'
vs/platform/actions/common/actions
'
;
import
{
MenuId
,
SyncActionDescriptor
,
registerAction2
,
Action2
}
from
'
vs/platform/actions/common/actions
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ContextKeyExpr
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
...
...
@@ -26,12 +26,14 @@ import { Extensions as EditorInputExtensions, IEditorInputFactory, IEditorInputF
import
*
as
SearchConstants
from
'
vs/workbench/contrib/search/common/constants
'
;
import
*
as
SearchEditorConstants
from
'
vs/workbench/contrib/searchEditor/browser/constants
'
;
import
{
SearchEditor
}
from
'
vs/workbench/contrib/searchEditor/browser/searchEditor
'
;
import
{
modifySearchEditorContextLinesCommand
,
Open
ResultsInEditorAction
,
OpenSearchEditorAction
,
OpenSearchEditorToSideAction
,
RerunSearchEditorSearchAction
,
selectAllSearchEditorMatchesCommand
,
toggleSearchEditorCaseSensitiveCommand
,
toggleSearchEditorContextLinesCommand
,
toggleSearchEditorRegexCommand
,
toggleSearchEditorWholeWordCommand
,
FocusQueryEditorWidgetAction
}
from
'
vs/workbench/contrib/searchEditor/browser/searchEditorActions
'
;
import
{
modifySearchEditorContextLinesCommand
,
Open
SearchEditorAction
,
selectAllSearchEditorMatchesCommand
,
toggleSearchEditorCaseSensitiveCommand
,
toggleSearchEditorContextLinesCommand
,
toggleSearchEditorRegexCommand
,
toggleSearchEditorWholeWordCommand
,
createEditorFromSearchResult
,
openNewSearchEditor
}
from
'
vs/workbench/contrib/searchEditor/browser/searchEditorActions
'
;
import
{
getOrMakeSearchEditorInput
,
SearchEditorInput
,
SearchConfiguration
}
from
'
vs/workbench/contrib/searchEditor/browser/searchEditorInput
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
parseSavedSearchEditor
}
from
'
vs/workbench/contrib/searchEditor/browser/searchEditorSerialization
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
searchRefreshIcon
}
from
'
vs/workbench/contrib/search/browser/searchIcons
'
;
import
{
IViewsService
}
from
'
vs/workbench/common/views
'
;
import
{
getSearchView
}
from
'
vs/workbench/contrib/search/browser/searchActions
'
;
//#region Editor Descriptior
Registry
.
as
<
IEditorRegistry
>
(
EditorExtensions
.
Editors
).
registerEditor
(
...
...
@@ -193,36 +195,105 @@ CommandsRegistry.registerCommand(
const
registry
=
Registry
.
as
<
IWorkbenchActionRegistry
>
(
ActionExtensions
.
WorkbenchActions
);
const
category
=
localize
(
'
search
'
,
"
Search Editor
"
);
registry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
from
(
OpenResultsInEditorAction
,
{
mac
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
Enter
}
},
ContextKeyExpr
.
and
(
SearchConstants
.
HasSearchResults
,
SearchConstants
.
SearchViewFocusedKey
)),
'
Search Editor: Open Results in Editor
'
,
category
);
// TODO: Not an action2 becuase used in view pane container action bar, which uses actions
registry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
from
(
OpenSearchEditorAction
),
'
Search Editor: Open New Search Editor
'
,
category
);
registry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
from
(
OpenSearchEditorToSideAction
),
'
Search Editor: Open New Search Editor to Side
'
,
category
);
registry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
from
(
RerunSearchEditorSearchAction
,
{
mac
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
KEY_R
}
}),
'
Search Editor: Search Again
'
,
category
,
SearchEditorConstants
.
InSearchEditor
);
registry
.
registerWorkbenchAction
(
SyncActionDescriptor
.
from
(
FocusQueryEditorWidgetAction
,
{
primary
:
KeyCode
.
Escape
}),
'
Search Editor: Focus Query Editor Widget
'
,
category
,
SearchEditorConstants
.
InSearchEditor
);
//#endregion
registerAction2
(
class
extends
Action2
{
constructor
()
{
super
({
id
:
SearchEditorConstants
.
OpenInEditorCommandId
,
title
:
localize
(
'
search.openResultsInEditor
'
,
"
Open Results in Editor
"
),
category
,
f1
:
true
,
keybinding
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
Enter
,
when
:
ContextKeyExpr
.
and
(
SearchConstants
.
HasSearchResults
,
SearchConstants
.
SearchViewFocusedKey
),
weight
:
KeybindingWeight
.
WorkbenchContrib
},
});
}
async
run
(
accessor
:
ServicesAccessor
)
{
const
viewsService
=
accessor
.
get
(
IViewsService
);
const
instantiationService
=
accessor
.
get
(
IInstantiationService
);
const
searchView
=
getSearchView
(
viewsService
);
if
(
searchView
)
{
await
instantiationService
.
invokeFunction
(
createEditorFromSearchResult
,
searchView
.
searchResult
,
searchView
.
searchIncludePattern
.
getValue
(),
searchView
.
searchExcludePattern
.
getValue
());
}
}
});
registerAction2
(
class
extends
Action2
{
constructor
()
{
super
({
id
:
SearchEditorConstants
.
OpenNewEditorToSideCommandId
,
title
:
localize
(
'
search.openNewEditorToSide
'
,
"
Open New Search Editor to Side
"
),
category
,
f1
:
true
,
});
}
async
run
(
accessor
:
ServicesAccessor
)
{
const
instantiationService
=
accessor
.
get
(
IInstantiationService
);
await
instantiationService
.
invokeFunction
(
openNewSearchEditor
,
true
);
}
});
MenuRegistry
.
appendMenuItem
(
MenuId
.
EditorTitle
,
{
command
:
{
id
:
RerunSearchEditorSearchAction
.
ID
,
title
:
RerunSearchEditorSearchAction
.
LABEL
,
icon
:
searchRefreshIcon
,
registerAction2
(
class
extends
Action2
{
constructor
()
{
super
({
id
:
SearchEditorConstants
.
RerunSearchEditorSearchCommandId
,
title
:
localize
(
'
search.rerunSearchInEditor
'
,
"
Search Again
"
),
category
,
keybinding
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
KEY_R
,
when
:
SearchEditorConstants
.
InSearchEditor
,
weight
:
KeybindingWeight
.
EditorContrib
},
icon
:
searchRefreshIcon
,
menu
:
[{
id
:
MenuId
.
EditorTitle
,
group
:
'
navigation
'
,
when
:
ContextKeyExpr
.
and
(
ActiveEditorContext
.
isEqualTo
(
SearchEditorConstants
.
SearchEditorID
))
when
:
ActiveEditorContext
.
isEqualTo
(
SearchEditorConstants
.
SearchEditorID
)
},
{
id
:
MenuId
.
CommandPalette
,
when
:
ActiveEditorContext
.
isEqualTo
(
SearchEditorConstants
.
SearchEditorID
)
}]
});
}
async
run
(
accessor
:
ServicesAccessor
)
{
const
editorService
=
accessor
.
get
(
IEditorService
);
const
input
=
editorService
.
activeEditor
;
if
(
input
instanceof
SearchEditorInput
)
{
(
editorService
.
activeEditorPane
as
SearchEditor
).
triggerSearch
({
resetCursor
:
false
});
}
}
});
registerAction2
(
class
extends
Action2
{
constructor
()
{
super
({
id
:
SearchEditorConstants
.
FocusQueryEditorWidgetCommandId
,
title
:
localize
(
'
search.action.focusQueryEditorWidget
'
,
"
Focus Search Editor Input
"
),
category
,
menu
:
{
id
:
MenuId
.
CommandPalette
,
when
:
ActiveEditorContext
.
isEqualTo
(
SearchEditorConstants
.
SearchEditorID
)
},
keybinding
:
{
primary
:
KeyCode
.
Escape
,
when
:
SearchEditorConstants
.
InSearchEditor
,
weight
:
KeybindingWeight
.
EditorContrib
}
});
}
async
run
(
accessor
:
ServicesAccessor
)
{
const
editorService
=
accessor
.
get
(
IEditorService
);
const
input
=
editorService
.
activeEditor
;
if
(
input
instanceof
SearchEditorInput
)
{
(
editorService
.
activeEditorPane
as
SearchEditor
).
focusSearchInput
();
}
}
});
//#endregion
src/vs/workbench/contrib/searchEditor/browser/searchEditorActions.ts
浏览文件 @
ebec7141
...
...
@@ -12,8 +12,6 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IViewsService
}
from
'
vs/workbench/common/views
'
;
import
{
getSearchView
}
from
'
vs/workbench/contrib/search/browser/searchActions
'
;
import
{
SearchResult
}
from
'
vs/workbench/contrib/search/common/searchModel
'
;
import
*
as
Constants
from
'
vs/workbench/contrib/searchEditor/browser/constants
'
;
import
{
SearchEditor
}
from
'
vs/workbench/contrib/searchEditor/browser/searchEditor
'
;
...
...
@@ -21,7 +19,7 @@ import { getOrMakeSearchEditorInput, SearchEditorInput } from 'vs/workbench/cont
import
{
serializeSearchResultForEditor
}
from
'
vs/workbench/contrib/searchEditor/browser/searchEditorSerialization
'
;
import
{
IEditorService
,
SIDE_GROUP
,
ACTIVE_GROUP
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
ISearchConfigurationProperties
}
from
'
vs/workbench/services/search/common/search
'
;
import
{
search
RefreshIcon
,
searchNewEditorIcon
,
searchGotoFile
Icon
}
from
'
vs/workbench/contrib/search/browser/searchIcons
'
;
import
{
search
NewEditor
Icon
}
from
'
vs/workbench/contrib/search/browser/searchIcons
'
;
export
const
toggleSearchEditorCaseSensitiveCommand
=
(
accessor
:
ServicesAccessor
)
=>
{
const
editorService
=
accessor
.
get
(
IEditorService
);
...
...
@@ -71,7 +69,6 @@ export const selectAllSearchEditorMatchesCommand = (accessor: ServicesAccessor)
}
};
export
class
OpenSearchEditorAction
extends
Action
{
static
readonly
ID
:
string
=
Constants
.
OpenNewEditorCommandId
;
...
...
@@ -96,88 +93,7 @@ export class OpenSearchEditorAction extends Action {
}
}
export
class
OpenSearchEditorToSideAction
extends
Action
{
static
readonly
ID
:
string
=
Constants
.
OpenNewEditorToSideCommandId
;
static
readonly
LABEL
=
localize
(
'
search.openNewEditorToSide
'
,
"
Open New Search Editor to Side
"
);
constructor
(
id
:
string
,
label
:
string
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
)
{
super
(
id
,
label
,
searchNewEditorIcon
.
classNames
);
}
async
run
()
{
await
this
.
instantiationService
.
invokeFunction
(
openNewSearchEditor
,
true
);
}
}
export
class
OpenResultsInEditorAction
extends
Action
{
static
readonly
ID
:
string
=
Constants
.
OpenInEditorCommandId
;
static
readonly
LABEL
=
localize
(
'
search.openResultsInEditor
'
,
"
Open Results in Editor
"
);
constructor
(
id
:
string
,
label
:
string
,
@
IViewsService
private
viewsService
:
IViewsService
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
)
{
super
(
id
,
label
,
searchGotoFileIcon
.
classNames
);
}
get
enabled
():
boolean
{
const
searchView
=
getSearchView
(
this
.
viewsService
);
return
!!
searchView
&&
searchView
.
hasSearchResults
();
}
update
()
{
this
.
_setEnabled
(
this
.
enabled
);
}
async
run
()
{
const
searchView
=
getSearchView
(
this
.
viewsService
);
if
(
searchView
)
{
await
this
.
instantiationService
.
invokeFunction
(
createEditorFromSearchResult
,
searchView
.
searchResult
,
searchView
.
searchIncludePattern
.
getValue
(),
searchView
.
searchExcludePattern
.
getValue
());
}
}
}
export
class
RerunSearchEditorSearchAction
extends
Action
{
static
readonly
ID
:
string
=
Constants
.
RerunSearchEditorSearchCommandId
;
static
readonly
LABEL
=
localize
(
'
search.rerunSearchInEditor
'
,
"
Search Again
"
);
constructor
(
id
:
string
,
label
:
string
,
@
IEditorService
private
readonly
editorService
:
IEditorService
,
)
{
super
(
id
,
label
,
searchRefreshIcon
.
classNames
);
}
async
run
()
{
const
input
=
this
.
editorService
.
activeEditor
;
if
(
input
instanceof
SearchEditorInput
)
{
(
this
.
editorService
.
activeEditorPane
as
SearchEditor
).
triggerSearch
({
resetCursor
:
false
});
}
}
}
export
class
FocusQueryEditorWidgetAction
extends
Action
{
static
readonly
ID
:
string
=
Constants
.
FocusQueryEditorWidgetCommandId
;
static
readonly
LABEL
=
localize
(
'
search.action.focusQueryEditorWidget
'
,
"
Focus Search Editor Input
"
);
constructor
(
id
:
string
,
label
:
string
,
@
IEditorService
private
readonly
editorService
:
IEditorService
,
)
{
super
(
id
,
label
);
}
async
run
()
{
const
input
=
this
.
editorService
.
activeEditor
;
if
(
input
instanceof
SearchEditorInput
)
{
(
this
.
editorService
.
activeEditorPane
as
SearchEditor
).
focusSearchInput
();
}
}
}
const
openNewSearchEditor
=
export
const
openNewSearchEditor
=
async
(
accessor
:
ServicesAccessor
,
toSide
=
false
)
=>
{
const
editorService
=
accessor
.
get
(
IEditorService
);
const
telemetryService
=
accessor
.
get
(
ITelemetryService
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录