Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
60bf96cc
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,发现更多精彩内容 >>
提交
60bf96cc
编写于
12月 21, 2017
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
find actions to commands
上级
4897f57c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
59 addition
and
128 deletion
+59
-128
src/vs/workbench/parts/search/electron-browser/search.contribution.ts
...ench/parts/search/electron-browser/search.contribution.ts
+59
-56
src/vs/workbench/parts/search/electron-browser/searchActions.ts
.../workbench/parts/search/electron-browser/searchActions.ts
+0
-72
未找到文件。
src/vs/workbench/parts/search/electron-browser/search.contribution.ts
浏览文件 @
60bf96cc
...
...
@@ -12,17 +12,14 @@ import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor } f
import
{
IConfigurationRegistry
,
Extensions
as
ConfigurationExtensions
,
ConfigurationScope
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IAction
,
Action
}
from
'
vs/base/common/actions
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
{
explorerItemToFileResource
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
SyncActionDescriptor
}
from
'
vs/platform/actions/common/actions
'
;
import
{
Separator
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
Scope
,
IActionBarRegistry
,
Extensions
as
ActionBarExtensions
,
ActionBarContributor
}
from
'
vs/workbench/browser/actions
'
;
import
{
explorerItemToFileResource
,
ExplorerFolderContext
,
ExplorerRootContext
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
SyncActionDescriptor
,
MenuRegistry
,
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IWorkbenchActionRegistry
,
Extensions
as
ActionExtensions
}
from
'
vs/workbench/common/actions
'
;
import
{
QuickOpenHandlerDescriptor
,
IQuickOpenRegistry
,
Extensions
as
QuickOpenExtensions
}
from
'
vs/workbench/browser/quickopen
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IQuickOpenService
}
from
'
vs/platform/quickOpen/common/quickOpen
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
getSelectionSearchString
}
from
'
vs/editor/contrib/find/findController
'
;
...
...
@@ -30,7 +27,6 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import
{
KeyMod
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
ITree
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
*
as
searchActions
from
'
vs/workbench/parts/search/browser/searchActions
'
;
import
{
Model
}
from
'
vs/workbench/parts/files/common/explorerModel
'
;
import
*
as
Constants
from
'
vs/workbench/parts/search/common/constants
'
;
import
{
registerContributions
as
replaceContributions
}
from
'
vs/workbench/parts/search/browser/replaceContributions
'
;
import
{
registerContributions
as
searchWidgetContributions
}
from
'
vs/workbench/parts/search/browser/searchWidget
'
;
...
...
@@ -45,9 +41,12 @@ import { OpenSymbolHandler } from 'vs/workbench/parts/search/browser/openSymbolH
import
{
OpenAnythingHandler
}
from
'
vs/workbench/parts/search/browser/openAnythingHandler
'
;
import
{
registerLanguageCommand
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
getWorkspaceSymbols
}
from
'
vs/workbench/parts/search/common/search
'
;
import
{
illegalArgument
}
from
'
vs/base/common/errors
'
;
import
{
FindInFolderAction
,
findInFolderCommand
,
FindInWorkspaceAction
}
from
'
vs/workbench/parts/search/electron-browser/searchActions
'
;
import
{
WorkbenchListFocusContextKey
}
from
'
vs/platform/list/browser/listService
'
;
import
{
illegalArgument
,
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
WorkbenchListFocusContextKey
,
IListService
}
from
'
vs/platform/list/browser/listService
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
relative
}
from
'
path
'
;
import
{
dirname
}
from
'
vs/base/common/resources
'
;
import
{
ResourceContextKey
}
from
'
vs/workbench/common/resources
'
;
registerSingleton
(
ISearchWorkbenchService
,
SearchWorkbenchService
);
replaceContributions
();
...
...
@@ -183,54 +182,62 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});
CommandsRegistry
.
registerCommand
(
FindInFolderAction
.
ID
,
findInFolderCommand
);
class
ExplorerViewerActionContributor
extends
ActionBarContributor
{
private
_instantiationService
:
IInstantiationService
;
constructor
(
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
)
{
super
();
this
.
_instantiationService
=
instantiationService
;
}
public
hasSecondaryActions
(
context
:
any
):
boolean
{
let
element
=
context
.
element
;
// Contribute only on file resources and model (context menu for multi root)
if
(
element
instanceof
Model
)
{
return
true
;
}
let
fileResource
=
explorerItemToFileResource
(
element
);
if
(
!
fileResource
)
{
return
false
;
const
FIND_IN_FOLDER_ID
=
'
filesExplorer.findInFolder
'
;
CommandsRegistry
.
registerCommand
({
id
:
FIND_IN_FOLDER_ID
,
handler
:
(
accessor
,
resource
?:
URI
)
=>
{
const
listService
=
accessor
.
get
(
IListService
);
const
viewletService
=
accessor
.
get
(
IViewletService
);
if
(
!
URI
.
isUri
(
resource
))
{
const
lastFocusedList
=
listService
.
lastFocusedList
;
const
focus
=
lastFocusedList
?
lastFocusedList
.
getFocus
()
:
void
0
;
if
(
focus
)
{
const
file
=
explorerItemToFileResource
(
focus
);
if
(
file
)
{
resource
=
file
.
isDirectory
?
file
.
resource
:
dirname
(
file
.
resource
);
}
}
}
return
fileResource
.
isDirectory
&&
fileResource
.
resource
.
scheme
===
'
file
'
;
}
public
getSecondaryActions
(
context
:
any
):
IAction
[]
{
let
actions
:
IAction
[]
=
[];
if
(
this
.
hasSecondaryActions
(
context
))
{
let
action
:
Action
;
if
(
context
.
element
instanceof
Model
)
{
action
=
this
.
_instantiationService
.
createInstance
(
FindInWorkspaceAction
);
}
else
{
let
fileResource
=
explorerItemToFileResource
(
context
.
element
);
action
=
this
.
_instantiationService
.
createInstance
(
FindInFolderAction
,
fileResource
.
resource
);
viewletService
.
openViewlet
(
Constants
.
VIEWLET_ID
,
true
).
then
(
viewlet
=>
{
if
(
resource
)
{
(
viewlet
as
SearchViewlet
).
searchInFolder
(
resource
,
(
from
,
to
)
=>
relative
(
from
,
to
));
}
}).
done
(
null
,
onUnexpectedError
);
}
});
action
.
order
=
55
;
actions
.
push
(
action
);
const
FIND_IN_WORKSPACE_ID
=
'
filesExplorer.findInWorkspace
'
;
CommandsRegistry
.
registerCommand
({
id
:
FIND_IN_WORKSPACE_ID
,
handler
:
(
accessor
,
)
=>
{
const
viewletService
=
accessor
.
get
(
IViewletService
);
return
viewletService
.
openViewlet
(
Constants
.
VIEWLET_ID
,
true
).
then
(
viewlet
=>
{
(
viewlet
as
SearchViewlet
).
searchInFolder
(
null
,
(
from
,
to
)
=>
relative
(
from
,
to
));
});
}
});
actions
.
push
(
new
Separator
(
''
,
56
));
}
MenuRegistry
.
appendMenuItem
(
MenuId
.
ExplorerContext
,
{
group
:
'
3_find
'
,
order
:
20
,
command
:
{
id
:
FIND_IN_FOLDER_ID
,
title
:
nls
.
localize
(
'
findInFolder
'
,
"
Find in Folder...
"
)
},
when
:
ContextKeyExpr
.
and
(
ExplorerFolderContext
,
ResourceContextKey
.
Scheme
.
isEqualTo
(
'
file
'
))
});
return
actions
;
}
}
MenuRegistry
.
appendMenuItem
(
MenuId
.
ExplorerContext
,
{
group
:
'
3_find
'
,
order
:
20
,
command
:
{
id
:
FIND_IN_WORKSPACE_ID
,
title
:
nls
.
localize
(
'
findInWorkspace
'
,
"
Find in Workspace...
"
)
},
when
:
ContextKeyExpr
.
and
(
ExplorerRootContext
,
ExplorerFolderContext
.
toNegated
())
});
const
ACTION_ID
=
'
workbench.action.showAllSymbols
'
;
const
ACTION_LABEL
=
nls
.
localize
(
'
showTriggerActions
'
,
"
Go to Symbol in Workspace...
"
);
...
...
@@ -327,10 +334,6 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(searchActions.ShowPrev
registry
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
ShowAllSymbolsAction
,
ACTION_ID
,
ACTION_LABEL
,
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_T
}),
'
Go to Symbol in Workspace...
'
);
// Contribute to Explorer Viewer
const
actionBarRegistry
=
Registry
.
as
<
IActionBarRegistry
>
(
ActionBarExtensions
.
Actionbar
);
actionBarRegistry
.
registerActionBarContributor
(
Scope
.
VIEWER
,
ExplorerViewerActionContributor
);
// Register Quick Open Handler
Registry
.
as
<
IQuickOpenRegistry
>
(
QuickOpenExtensions
.
Quickopen
).
registerDefaultQuickOpenHandler
(
new
QuickOpenHandlerDescriptor
(
...
...
src/vs/workbench/parts/search/electron-browser/searchActions.ts
已删除
100644 → 0
浏览文件 @
4897f57c
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
nls
=
require
(
'
vs/nls
'
);
import
errors
=
require
(
'
vs/base/common/errors
'
);
import
resources
=
require
(
'
vs/base/common/resources
'
);
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
import
{
SearchViewlet
}
from
'
vs/workbench/parts/search/browser/searchViewlet
'
;
import
*
as
Constants
from
'
vs/workbench/parts/search/common/constants
'
;
import
{
ServicesAccessor
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IListService
}
from
'
vs/platform/list/browser/listService
'
;
import
{
explorerItemToFileResource
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
relative
}
from
'
path
'
;
export
class
FindInFolderAction
extends
Action
{
public
static
readonly
ID
=
'
filesExplorer.findInFolder
'
;
private
resource
:
URI
;
constructor
(
resource
:
URI
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
)
{
super
(
FindInFolderAction
.
ID
,
nls
.
localize
(
'
findInFolder
'
,
"
Find in Folder...
"
));
this
.
resource
=
resource
;
}
public
run
(
event
?:
any
):
TPromise
<
any
>
{
return
this
.
instantiationService
.
invokeFunction
.
apply
(
this
.
instantiationService
,
[
findInFolderCommand
,
this
.
resource
]);
}
}
export
const
findInFolderCommand
=
(
accessor
:
ServicesAccessor
,
resource
?:
URI
)
=>
{
const
listService
=
accessor
.
get
(
IListService
);
const
viewletService
=
accessor
.
get
(
IViewletService
);
if
(
!
URI
.
isUri
(
resource
))
{
const
lastFocusedList
=
listService
.
lastFocusedList
;
const
focus
=
lastFocusedList
?
lastFocusedList
.
getFocus
()
:
void
0
;
if
(
focus
)
{
const
file
=
explorerItemToFileResource
(
focus
);
if
(
file
)
{
resource
=
file
.
isDirectory
?
file
.
resource
:
resources
.
dirname
(
file
.
resource
);
}
}
}
viewletService
.
openViewlet
(
Constants
.
VIEWLET_ID
,
true
).
then
(
viewlet
=>
{
if
(
resource
)
{
(
viewlet
as
SearchViewlet
).
searchInFolder
(
resource
,
(
from
,
to
)
=>
relative
(
from
,
to
));
}
}).
done
(
null
,
errors
.
onUnexpectedError
);
};
export
class
FindInWorkspaceAction
extends
Action
{
public
static
readonly
ID
=
'
filesExplorer.findInWorkspace
'
;
constructor
(
@
IViewletService
private
viewletService
:
IViewletService
)
{
super
(
FindInWorkspaceAction
.
ID
,
nls
.
localize
(
'
findInWorkspace
'
,
"
Find in Workspace...
"
));
}
public
run
(
event
?:
any
):
TPromise
<
any
>
{
return
this
.
viewletService
.
openViewlet
(
Constants
.
VIEWLET_ID
,
true
).
then
(
viewlet
=>
{
(
viewlet
as
SearchViewlet
).
searchInFolder
(
null
,
(
from
,
to
)
=>
relative
(
from
,
to
));
});
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录