Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
7180bb92
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,发现更多精彩内容 >>
提交
7180bb92
编写于
8月 10, 2018
作者:
C
Christof Marti
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use QuickInput (#29096)
上级
5d8c7829
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
54 addition
and
60 deletion
+54
-60
src/vs/workbench/electron-browser/actions.ts
src/vs/workbench/electron-browser/actions.ts
+54
-60
未找到文件。
src/vs/workbench/electron-browser/actions.ts
浏览文件 @
7180bb92
...
...
@@ -9,7 +9,7 @@ import 'vs/css!./media/actions';
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Action
,
IAction
}
from
'
vs/base/common/actions
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
IWindowService
,
IWindowsService
,
MenuBarVisibility
}
from
'
vs/platform/windows/common/windows
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
product
from
'
vs/platform/node/product
'
;
...
...
@@ -20,10 +20,8 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import
{
IConfigurationService
,
ConfigurationTarget
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IWorkspaceConfigurationService
}
from
'
vs/workbench/services/configuration/common/configuration
'
;
import
{
isMacintosh
,
isLinux
,
language
}
from
'
vs/base/common/platform
'
;
import
{
IQuickOpenService
,
IFilePickOpenEntry
,
ISeparator
,
IPickOpenAction
,
IPickOpenItem
}
from
'
vs/platform/quickOpen/common/quickOpen
'
;
import
*
as
browser
from
'
vs/base/browser/browser
'
;
import
{
IIntegrityService
}
from
'
vs/platform/integrity/common/integrity
'
;
import
{
IEntryRunContext
}
from
'
vs/base/parts/quickopen/common/quickOpen
'
;
import
{
ITimerService
,
IStartupMetrics
}
from
'
vs/workbench/services/timer/common/timerService
'
;
import
{
IEditorGroupsService
,
GroupDirection
,
GroupLocation
,
IFindGroupScope
}
from
'
vs/workbench/services/group/common/editorGroupsService
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
...
...
@@ -37,7 +35,6 @@ import { IViewlet } from 'vs/workbench/common/viewlet';
import
{
IPanel
}
from
'
vs/workbench/common/panel
'
;
import
{
IWorkspaceIdentifier
,
getWorkspaceLabel
,
ISingleFolderWorkspaceIdentifier
,
isSingleFolderWorkspaceIdentifier
,
isWorkspaceIdentifier
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
FileKind
}
from
'
vs/platform/files/common/files
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IExtensionService
,
ActivationTimes
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
getEntries
}
from
'
vs/base/common/performance
'
;
import
{
IssueType
}
from
'
vs/platform/issue/common/issue
'
;
...
...
@@ -53,7 +50,7 @@ import { IUriDisplayService } from 'vs/platform/uriDisplay/common/uriDisplay';
import
{
dirname
}
from
'
vs/base/common/resources
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IQuickInputService
,
IQuickPickItem
,
IQuickInputButton
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
IQuickInputService
,
IQuickPickItem
,
IQuickInputButton
,
IQuickPickSeparator
,
IKeyMods
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
getIconClasses
}
from
'
vs/workbench/browser/labels
'
;
// --- actions
...
...
@@ -654,7 +651,6 @@ export class SwitchWindow extends BaseSwitchWindow {
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
IModelService
modelService
:
IModelService
,
@
IModeService
modeService
:
IModeService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
)
{
super
(
id
,
label
,
windowsService
,
windowService
,
quickInputService
,
keybindingService
,
modelService
,
modeService
);
}
...
...
@@ -678,7 +674,6 @@ export class QuickSwitchWindow extends BaseSwitchWindow {
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
IModelService
modelService
:
IModelService
,
@
IModeService
modeService
:
IModeService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
)
{
super
(
id
,
label
,
windowsService
,
windowService
,
quickInputService
,
keybindingService
,
modelService
,
modeService
);
}
...
...
@@ -692,16 +687,23 @@ export const inRecentFilesPickerContextKey = 'inRecentFilesPicker';
export
abstract
class
BaseOpenRecentAction
extends
Action
{
private
removeFromRecentlyOpened
:
IQuickInputButton
=
{
iconClass
:
'
action-remove-from-recently-opened
'
,
tooltip
:
nls
.
localize
(
'
remove
'
,
"
Remove from Recently Opened
"
)
};
constructor
(
id
:
string
,
label
:
string
,
private
windowService
:
IWindowService
,
private
quickOpenService
:
IQuickOpenService
,
private
windowsService
:
IWindowsService
,
private
quickInputService
:
IQuickInputService
,
private
contextService
:
IWorkspaceContextService
,
private
environmentService
:
IEnvironmentService
,
private
uriDisplayService
:
IUriDisplayService
,
private
keybindingService
:
IKeybindingService
,
private
instantiationService
:
IInstantiationService
private
modelService
:
IModelService
,
private
modeService
:
IModeService
,
)
{
super
(
id
,
label
);
}
...
...
@@ -715,7 +717,7 @@ export abstract class BaseOpenRecentAction extends Action {
private
openRecent
(
recentWorkspaces
:
(
IWorkspaceIdentifier
|
ISingleFolderWorkspaceIdentifier
)[],
recentFiles
:
string
[]):
void
{
function
toPick
(
workspace
:
IWorkspaceIdentifier
|
ISingleFolderWorkspaceIdentifier
|
string
,
separator
:
ISeparator
,
fileKind
:
FileKind
,
environmentService
:
IEnvironmentService
,
uriDisplayService
:
IUriDisplayService
,
action
:
IAction
):
IFilePickOpenEntry
{
const
toPick
=
(
workspace
:
IWorkspaceIdentifier
|
ISingleFolderWorkspaceIdentifier
|
string
,
fileKind
:
FileKind
,
environmentService
:
IEnvironmentService
,
uriDisplayService
:
IUriDisplayService
,
buttons
:
IQuickInputButton
[])
=>
{
let
resource
:
URI
;
let
label
:
string
;
let
description
:
string
;
...
...
@@ -734,63 +736,51 @@ export abstract class BaseOpenRecentAction extends Action {
}
return
{
resource
,
fileKind
,
iconClasses
:
getIconClasses
(
this
.
modelService
,
this
.
modeService
,
resource
,
fileKind
),
label
,
description
,
separator
,
run
:
context
=>
{
setTimeout
(()
=>
{
// Bug: somehow when not running this code in a timeout, it is not possible to use this picker
// with quick navigate keys (not able to trigger quick navigate once running it once).
runPick
(
resource
,
fileKind
===
FileKind
.
FILE
,
context
);
});
},
action
buttons
,
workspace
,
resource
,
fileKind
,
};
};
}
const
runPick
=
(
resource
:
URI
,
isFile
:
boolean
,
context
:
IEntryRunContext
)
=>
{
const
forceNewWindow
=
context
.
keym
ods
.
ctrlCmd
;
this
.
windowService
.
openWindow
([
resource
],
{
forceNewWindow
,
forceOpenWorkspaceAsFile
:
isFile
});
const
runPick
=
(
resource
:
URI
,
isFile
:
boolean
,
keyMods
:
IKeyMods
)
=>
{
const
forceNewWindow
=
keyM
ods
.
ctrlCmd
;
return
this
.
windowService
.
openWindow
([
resource
],
{
forceNewWindow
,
forceOpenWorkspaceAsFile
:
isFile
});
};
const
workspacePicks
:
IFilePickOpenEntry
[]
=
recentWorkspaces
.
map
((
workspace
,
index
)
=>
toPick
(
workspace
,
index
===
0
?
{
label
:
nls
.
localize
(
'
workspaces
'
,
"
workspaces
"
)
}
:
void
0
,
isSingleFolderWorkspaceIdentifier
(
workspace
)
?
FileKind
.
FOLDER
:
FileKind
.
ROOT_FOLDER
,
this
.
environmentService
,
this
.
uriDisplayService
,
!
this
.
isQuickNavigate
()
?
this
.
instantiationService
.
createInstance
(
RemoveFromRecentlyOpened
,
workspace
)
:
void
0
));
const
filePicks
:
IFilePickOpenEntry
[]
=
recentFiles
.
map
((
p
,
index
)
=>
toPick
(
p
,
index
===
0
?
{
label
:
nls
.
localize
(
'
files
'
,
"
files
"
),
border
:
true
}
:
void
0
,
FileKind
.
FILE
,
this
.
environmentService
,
this
.
uriDisplayService
,
!
this
.
isQuickNavigate
()
?
this
.
instantiationService
.
createInstance
(
RemoveFromRecentlyOpened
,
p
)
:
void
0
));
const
workspacePicks
=
recentWorkspaces
.
map
(
workspace
=>
toPick
(
workspace
,
isSingleFolderWorkspaceIdentifier
(
workspace
)
?
FileKind
.
FOLDER
:
FileKind
.
ROOT_FOLDER
,
this
.
environmentService
,
this
.
uriDisplayService
,
!
this
.
isQuickNavigate
()
?
[
this
.
removeFromRecentlyOpened
]
:
void
0
));
const
filePicks
=
recentFiles
.
map
(
p
=>
toPick
(
p
,
FileKind
.
FILE
,
this
.
environmentService
,
this
.
uriDisplayService
,
!
this
.
isQuickNavigate
()
?
[
this
.
removeFromRecentlyOpened
]
:
void
0
));
// focus second entry if the first recent workspace is the current workspace
let
autoFocusSecondEntry
:
boolean
=
recentWorkspaces
[
0
]
&&
this
.
contextService
.
isCurrentWorkspace
(
recentWorkspaces
[
0
]);
this
.
quickOpenService
.
pick
([...
workspacePicks
,
...
filePicks
],
{
let
keyMods
:
IKeyMods
;
const
workspaceSeparator
:
IQuickPickSeparator
=
{
type
:
'
separator
'
,
label
:
nls
.
localize
(
'
workspaces
'
,
"
workspaces
"
)
};
const
fileSeparator
:
IQuickPickSeparator
=
{
type
:
'
separator
'
,
label
:
nls
.
localize
(
'
files
'
,
"
files
"
),
border
:
true
};
const
picks
=
[
workspaceSeparator
,
...
workspacePicks
,
fileSeparator
,
...
filePicks
];
this
.
quickInputService
.
pick
(
picks
,
{
contextKey
:
inRecentFilesPickerContextKey
,
a
utoFocus
:
{
autoFocusFirstEntry
:
!
autoFocusSecondEntry
,
autoFocusSecondEntry
:
autoFocusSecondEntry
}
,
a
ctiveItem
:
[...
workspacePicks
,
...
filePicks
][
autoFocusSecondEntry
?
1
:
0
]
,
placeHolder
:
isMacintosh
?
nls
.
localize
(
'
openRecentPlaceHolderMac
'
,
"
Select to open (hold Cmd-key to open in new window)
"
)
:
nls
.
localize
(
'
openRecentPlaceHolder
'
,
"
Select to open (hold Ctrl-key to open in new window)
"
),
matchOnDescription
:
true
,
quickNavigateConfiguration
:
this
.
isQuickNavigate
()
?
{
keybindings
:
this
.
keybindingService
.
lookupKeybindings
(
this
.
id
)
}
:
void
0
}).
done
(
null
,
errors
.
onUnexpectedError
);
onKeyMods
:
mods
=>
keyMods
=
mods
,
quickNavigate
:
this
.
isQuickNavigate
()
?
{
keybindings
:
this
.
keybindingService
.
lookupKeybindings
(
this
.
id
)
}
:
void
0
,
onDidTriggerItemButton
:
context
=>
{
this
.
windowsService
.
removeFromRecentlyOpened
([
context
.
item
.
workspace
]).
then
(()
=>
{
context
.
removeItem
();
}).
then
(
null
,
errors
.
onUnexpectedError
);
}
}
class
RemoveFromRecentlyOpened
extends
Action
implements
IPickOpenAction
{
static
readonly
ID
=
'
workbench.action.removeFromRecentlyOpened
'
;
static
readonly
LABEL
=
nls
.
localize
(
'
remove
'
,
"
Remove from Recently Opened
"
);
constructor
(
private
path
:
(
IWorkspaceIdentifier
|
ISingleFolderWorkspaceIdentifier
|
string
),
@
IWindowsService
private
windowsService
:
IWindowsService
)
{
super
(
RemoveFromRecentlyOpened
.
ID
,
RemoveFromRecentlyOpened
.
LABEL
);
this
.
class
=
'
action-remove-from-recently-opened
'
;
})
.
then
(
pick
=>
{
if
(
pick
)
{
return
runPick
(
pick
.
resource
,
pick
.
fileKind
===
FileKind
.
FILE
,
keyMods
);
}
run
(
item
:
IPickOpenItem
):
TPromise
<
boolean
>
{
return
this
.
windowsService
.
removeFromRecentlyOpened
([
this
.
path
]).
then
(()
=>
{
item
.
remove
();
return
true
;
});
return
null
;
})
.
done
(
null
,
errors
.
onUnexpectedError
);
}
}
...
...
@@ -803,14 +793,16 @@ export class OpenRecentAction extends BaseOpenRecentAction {
id
:
string
,
label
:
string
,
@
IWindowService
windowService
:
IWindowService
,
@
IQuickOpenService
quickOpenService
:
IQuickOpenService
,
@
IWindowsService
windowsService
:
IWindowsService
,
@
IQuickInputService
quickInputService
:
IQuickInputService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IEnvironmentService
environmentService
:
IEnvironmentService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IModelService
modelService
:
IModelService
,
@
IModeService
modeService
:
IModeService
,
@
IUriDisplayService
uriDisplayService
:
IUriDisplayService
)
{
super
(
id
,
label
,
windowService
,
quickOpenService
,
contextService
,
environmentService
,
uriDisplayService
,
keybindingService
,
instantiation
Service
);
super
(
id
,
label
,
windowService
,
windowsService
,
quickInputService
,
contextService
,
environmentService
,
uriDisplayService
,
keybindingService
,
modelService
,
mode
Service
);
}
protected
isQuickNavigate
():
boolean
{
...
...
@@ -827,14 +819,16 @@ export class QuickOpenRecentAction extends BaseOpenRecentAction {
id
:
string
,
label
:
string
,
@
IWindowService
windowService
:
IWindowService
,
@
IQuickOpenService
quickOpenService
:
IQuickOpenService
,
@
IWindowsService
windowsService
:
IWindowsService
,
@
IQuickInputService
quickInputService
:
IQuickInputService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IEnvironmentService
environmentService
:
IEnvironmentService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IModelService
modelService
:
IModelService
,
@
IModeService
modeService
:
IModeService
,
@
IUriDisplayService
uriDisplayService
:
IUriDisplayService
)
{
super
(
id
,
label
,
windowService
,
quickOpenService
,
contextService
,
environmentService
,
uriDisplayService
,
keybindingService
,
instantiation
Service
);
super
(
id
,
label
,
windowService
,
windowsService
,
quickInputService
,
contextService
,
environmentService
,
uriDisplayService
,
keybindingService
,
modelService
,
mode
Service
);
}
protected
isQuickNavigate
():
boolean
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录