Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
eaf60f88
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,发现更多精彩内容 >>
提交
eaf60f88
编写于
3月 24, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quick access - support to auto activate LAST
上级
4f0b2b06
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
63 addition
and
31 deletion
+63
-31
src/vs/base/parts/quickinput/browser/quickInput.ts
src/vs/base/parts/quickinput/browser/quickInput.ts
+18
-11
src/vs/base/parts/quickinput/common/quickInput.ts
src/vs/base/parts/quickinput/common/quickInput.ts
+11
-8
src/vs/platform/quickinput/browser/quickAccess.ts
src/vs/platform/quickinput/browser/quickAccess.ts
+2
-2
src/vs/platform/quickinput/common/quickAccess.ts
src/vs/platform/quickinput/common/quickAccess.ts
+4
-2
src/vs/workbench/browser/parts/editor/editor.contribution.ts
src/vs/workbench/browser/parts/editor/editor.contribution.ts
+3
-1
src/vs/workbench/browser/parts/editor/editorActions.ts
src/vs/workbench/browser/parts/editor/editorActions.ts
+10
-5
src/vs/workbench/browser/parts/quickopen/quickOpenController.ts
.../workbench/browser/parts/quickopen/quickOpenController.ts
+15
-2
未找到文件。
src/vs/base/parts/quickinput/browser/quickInput.ts
浏览文件 @
eaf60f88
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
'
vs/css!./media/quickInput
'
;
import
{
IQuickPickItem
,
IPickOptions
,
IInputOptions
,
IQuickNavigateConfiguration
,
IQuickPick
,
IQuickInput
,
IQuickInputButton
,
IInputBox
,
IQuickPickItemButtonEvent
,
QuickPickInput
,
IQuickPickSeparator
,
IKeyMods
,
IQuickPickAcceptEvent
,
NO_KEY_MODS
}
from
'
vs/base/parts/quickinput/common/quickInput
'
;
import
{
IQuickPickItem
,
IPickOptions
,
IInputOptions
,
IQuickNavigateConfiguration
,
IQuickPick
,
IQuickInput
,
IQuickInputButton
,
IInputBox
,
IQuickPickItemButtonEvent
,
QuickPickInput
,
IQuickPickSeparator
,
IKeyMods
,
IQuickPickAcceptEvent
,
NO_KEY_MODS
,
ItemActivation
}
from
'
vs/base/parts/quickinput/common/quickInput
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
QuickInputList
,
QuickInputListFocus
}
from
'
./quickInputList
'
;
...
...
@@ -391,7 +391,7 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
private
_matchOnLabel
=
true
;
private
_sortByLabel
=
true
;
private
_autoFocusOnList
=
true
;
private
_
autoFocusSecondEntry
=
false
;
private
_
itemActivation
=
ItemActivation
.
FIRST
;
private
_activeItems
:
T
[]
=
[];
private
activeItemsUpdated
=
false
;
private
activeItemsToConfirm
:
T
[]
|
null
=
[];
...
...
@@ -527,12 +527,12 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
this
.
update
();
}
get
autoFocusSecondEntry
()
{
return
this
.
_
autoFocusSecondEntry
;
get
itemActivation
()
{
return
this
.
_
itemActivation
;
}
set
autoFocusSecondEntry
(
autoFocusSecondEntry
:
boolea
n
)
{
this
.
_
autoFocusSecondEntry
=
autoFocusSecondEntry
;
set
itemActivation
(
itemActivation
:
ItemActivatio
n
)
{
this
.
_
itemActivation
=
itemActivation
;
}
get
activeItems
()
{
...
...
@@ -879,11 +879,18 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
this
.
ui
.
checkAll
.
checked
=
this
.
ui
.
list
.
getAllVisibleChecked
();
this
.
ui
.
visibleCount
.
setCount
(
this
.
ui
.
list
.
getVisibleCount
());
this
.
ui
.
count
.
setCount
(
this
.
ui
.
list
.
getCheckedCount
());
if
(
this
.
_autoFocusSecondEntry
)
{
this
.
ui
.
list
.
focus
(
QuickInputListFocus
.
Second
);
this
.
_autoFocusSecondEntry
=
false
;
// only valid once, then unset
}
else
{
this
.
trySelectFirst
();
switch
(
this
.
_itemActivation
)
{
case
ItemActivation
.
SECOND
:
this
.
ui
.
list
.
focus
(
QuickInputListFocus
.
Second
);
this
.
_itemActivation
=
ItemActivation
.
FIRST
;
// only valid once, then unset
break
;
case
ItemActivation
.
LAST
:
this
.
ui
.
list
.
focus
(
QuickInputListFocus
.
Last
);
this
.
_itemActivation
=
ItemActivation
.
FIRST
;
// only valid once, then unset
break
;
default
:
this
.
trySelectFirst
();
break
;
}
}
if
(
this
.
ui
.
container
.
classList
.
contains
(
'
show-checkboxes
'
)
!==
!!
this
.
canSelectMany
)
{
...
...
src/vs/base/parts/quickinput/common/quickInput.ts
浏览文件 @
eaf60f88
...
...
@@ -182,6 +182,12 @@ export interface IQuickPickAcceptEvent {
inBackground
:
boolean
;
}
export
enum
ItemActivation
{
FIRST
=
1
,
SECOND
,
LAST
}
export
interface
IQuickPick
<
T
extends
IQuickPickItem
>
extends
IQuickInput
{
value
:
string
;
...
...
@@ -237,20 +243,17 @@ export interface IQuickPick<T extends IQuickPickItem> extends IQuickInput {
autoFocusOnList
:
boolean
;
/**
* If enabled, will try to select the second entry of the picks
* once they appear instead of the first one. This is useful
* e.g. when `quickNavigate` is enabled to be able to select
* a previous entry by just releasing the quick nav keys.
*/
autoFocusSecondEntry
:
boolean
;
quickNavigate
:
IQuickNavigateConfiguration
|
undefined
;
activeItems
:
ReadonlyArray
<
T
>
;
readonly
onDidChangeActive
:
Event
<
T
[]
>
;
/**
* Allows to control which entry should be activated by default.
*/
itemActivation
:
ItemActivation
;
selectedItems
:
ReadonlyArray
<
T
>
;
readonly
onDidChangeSelection
:
Event
<
T
[]
>
;
...
...
src/vs/platform/quickinput/browser/quickAccess.ts
浏览文件 @
eaf60f88
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
IQuickInputService
,
IQuickPick
,
IQuickPickItem
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
IQuickInputService
,
IQuickPick
,
IQuickPickItem
,
ItemActivation
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
Disposable
,
DisposableStore
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IQuickAccessController
,
IQuickAccessProvider
,
IQuickAccessRegistry
,
Extensions
,
IQuickAccessProviderDescriptor
,
IQuickAccessOptions
,
DefaultQuickAccessFilterValue
}
from
'
vs/platform/quickinput/common/quickAccess
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
...
...
@@ -102,7 +102,7 @@ export class QuickAccessController extends Disposable implements IQuickAccessCon
picker
.
placeholder
=
descriptor
?.
placeholder
;
picker
.
quickNavigate
=
options
?.
quickNavigateConfiguration
;
picker
.
hideInput
=
!!
picker
.
quickNavigate
&&
!
visibleQuickAccess
;
// only hide input if there was no picker opened already
picker
.
autoFocusSecondEntry
=
!!
options
?.
quickNavigateConfiguration
||
!!
options
?.
autoFocus
?.
autoFocusSecondEntry
;
picker
.
itemActivation
=
options
?.
itemActivation
||
(
options
?.
quickNavigateConfiguration
?
ItemActivation
.
SECOND
:
ItemActivation
.
FIRST
)
;
picker
.
contextKey
=
descriptor
?.
contextKey
;
picker
.
filterValue
=
(
value
:
string
)
=>
value
.
substring
(
descriptor
?
descriptor
.
prefix
.
length
:
0
);
...
...
src/vs/platform/quickinput/common/quickAccess.ts
浏览文件 @
eaf60f88
...
...
@@ -9,6 +9,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
import
{
first
,
coalesce
}
from
'
vs/base/common/arrays
'
;
import
{
startsWith
}
from
'
vs/base/common/strings
'
;
import
{
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ItemActivation
}
from
'
vs/base/parts/quickinput/common/quickInput
'
;
export
interface
IQuickAccessOptions
{
...
...
@@ -18,9 +19,10 @@ export interface IQuickAccessOptions {
quickNavigateConfiguration
?:
IQuickNavigateConfiguration
;
/**
* Wether to select the second pick item by default instead of the first.
* Allows to configure a different item activation strategy.
* By default the first item in the list will get activated.
*/
autoFocus
?:
{
autoFocusSecondEntry
?:
boolean
}
itemActivation
?:
ItemActivation
}
export
interface
IQuickAccessController
{
...
...
src/vs/workbench/browser/parts/editor/editor.contribution.ts
浏览文件 @
eaf60f88
...
...
@@ -36,7 +36,9 @@ import {
SplitEditorUpAction
,
SplitEditorDownAction
,
MoveEditorToLeftGroupAction
,
MoveEditorToRightGroupAction
,
MoveEditorToAboveGroupAction
,
MoveEditorToBelowGroupAction
,
CloseAllEditorGroupsAction
,
JoinAllGroupsAction
,
FocusLeftGroup
,
FocusAboveGroup
,
FocusRightGroup
,
FocusBelowGroup
,
EditorLayoutSingleAction
,
EditorLayoutTwoColumnsAction
,
EditorLayoutThreeColumnsAction
,
EditorLayoutTwoByTwoGridAction
,
EditorLayoutTwoRowsAction
,
EditorLayoutThreeRowsAction
,
EditorLayoutTwoColumnsBottomAction
,
EditorLayoutTwoRowsRightAction
,
NewEditorGroupLeftAction
,
NewEditorGroupRightAction
,
NewEditorGroupAboveAction
,
NewEditorGroupBelowAction
,
SplitEditorOrthogonalAction
,
CloseEditorInAllGroupsAction
,
NavigateToLastEditLocationAction
,
ToggleGroupSizesAction
,
ShowAllEditorsByMostRecentlyUsedAction
,
QuickOpenPreviousRecentlyUsedEditorAction
,
OpenPreviousRecentlyUsedEditorInGroupAction
,
OpenNextRecentlyUsedEditorInGroupAction
,
QuickOpenNextRecentlyUsedEditorAction
as
QuickOpenLeastRecentlyUsedEditorAction
,
QuickOpenLeastRecentlyUsedEditorInGroupAction
NewEditorGroupAboveAction
,
NewEditorGroupBelowAction
,
SplitEditorOrthogonalAction
,
CloseEditorInAllGroupsAction
,
NavigateToLastEditLocationAction
,
ToggleGroupSizesAction
,
ShowAllEditorsByMostRecentlyUsedAction
,
QuickOpenPreviousRecentlyUsedEditorAction
,
OpenPreviousRecentlyUsedEditorInGroupAction
,
OpenNextRecentlyUsedEditorInGroupAction
,
QuickOpenNextRecentlyUsedEditorAction
as
QuickOpenLeastRecentlyUsedEditorAction
,
QuickOpenLeastRecentlyUsedEditorInGroupAction
}
from
'
vs/workbench/browser/parts/editor/editorActions
'
;
import
*
as
editorCommands
from
'
vs/workbench/browser/parts/editor/editorCommands
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
...
...
src/vs/workbench/browser/parts/editor/editorActions.ts
浏览文件 @
eaf60f88
...
...
@@ -24,6 +24,7 @@ import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
import
{
IFileDialogService
,
ConfirmResult
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
IWorkingCopyService
}
from
'
vs/workbench/services/workingCopy/common/workingCopyService
'
;
import
{
values
}
from
'
vs/base/common/map
'
;
import
{
ItemActivation
}
from
'
vs/platform/quickinput/common/quickInput
'
;
export
class
ExecuteCommandAction
extends
Action
{
...
...
@@ -1261,6 +1262,7 @@ export class BaseQuickOpenEditorAction extends Action {
id
:
string
,
label
:
string
,
private
prefix
:
string
,
private
itemActivation
:
ItemActivation
|
undefined
,
@
IQuickOpenService
private
readonly
quickOpenService
:
IQuickOpenService
,
@
IKeybindingService
private
readonly
keybindingService
:
IKeybindingService
)
{
...
...
@@ -1270,7 +1272,10 @@ export class BaseQuickOpenEditorAction extends Action {
async
run
():
Promise
<
void
>
{
const
keybindings
=
this
.
keybindingService
.
lookupKeybindings
(
this
.
id
);
this
.
quickOpenService
.
show
(
this
.
prefix
,
{
quickNavigateConfiguration
:
{
keybindings
}
});
this
.
quickOpenService
.
show
(
this
.
prefix
,
{
quickNavigateConfiguration
:
{
keybindings
},
autoFocus
:
this
.
itemActivation
===
ItemActivation
.
LAST
?
{
autoFocusLastEntry
:
true
}
:
undefined
});
}
}
...
...
@@ -1285,7 +1290,7 @@ export class QuickOpenPreviousRecentlyUsedEditorAction extends BaseQuickOpenEdit
@
IQuickOpenService
quickOpenService
:
IQuickOpenService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
)
{
super
(
id
,
label
,
NAVIGATE_ALL_EDITORS_BY_MOST_RECENTLY_USED_PREFIX
,
quickOpenService
,
keybindingService
);
super
(
id
,
label
,
NAVIGATE_ALL_EDITORS_BY_MOST_RECENTLY_USED_PREFIX
,
undefined
,
quickOpenService
,
keybindingService
);
}
}
...
...
@@ -1300,7 +1305,7 @@ export class QuickOpenNextRecentlyUsedEditorAction extends BaseQuickOpenEditorAc
@
IQuickOpenService
quickOpenService
:
IQuickOpenService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
)
{
super
(
id
,
label
,
NAVIGATE_ALL_EDITORS_BY_MOST_RECENTLY_USED_PREFIX
,
quickOpenService
,
keybindingService
);
super
(
id
,
label
,
NAVIGATE_ALL_EDITORS_BY_MOST_RECENTLY_USED_PREFIX
,
undefined
,
quickOpenService
,
keybindingService
);
}
}
...
...
@@ -1315,7 +1320,7 @@ export class QuickOpenPreviousRecentlyUsedEditorInGroupAction extends BaseQuickO
@
IQuickOpenService
quickOpenService
:
IQuickOpenService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
)
{
super
(
id
,
label
,
NAVIGATE_IN_ACTIVE_GROUP_BY_MOST_RECENTLY_USED_PREFIX
,
quickOpenService
,
keybindingService
);
super
(
id
,
label
,
NAVIGATE_IN_ACTIVE_GROUP_BY_MOST_RECENTLY_USED_PREFIX
,
undefined
,
quickOpenService
,
keybindingService
);
}
}
...
...
@@ -1330,7 +1335,7 @@ export class QuickOpenLeastRecentlyUsedEditorInGroupAction extends BaseQuickOpen
@
IQuickOpenService
quickOpenService
:
IQuickOpenService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
)
{
super
(
id
,
label
,
NAVIGATE_IN_ACTIVE_GROUP_BY_MOST_RECENTLY_USED_PREFIX
,
quickOpenService
,
keybindingService
);
super
(
id
,
label
,
NAVIGATE_IN_ACTIVE_GROUP_BY_MOST_RECENTLY_USED_PREFIX
,
ItemActivation
.
LAST
,
quickOpenService
,
keybindingService
);
}
}
...
...
src/vs/workbench/browser/parts/quickopen/quickOpenController.ts
浏览文件 @
eaf60f88
...
...
@@ -47,7 +47,7 @@ import { IEditorService, ACTIVE_GROUP, SIDE_GROUP } from 'vs/workbench/services/
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
timeout
}
from
'
vs/base/common/async
'
;
import
{
IQuickInputService
,
IQuickPickItem
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
IQuickInputService
,
IQuickPickItem
,
ItemActivation
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
CancellationTokenSource
,
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
...
...
@@ -179,7 +179,20 @@ export class QuickOpenController extends Component implements IQuickOpenService
show
(
prefix
?:
string
,
options
?:
IShowOptions
):
Promise
<
void
>
{
if
(
this
.
useNewExperimentalVersion
)
{
this
.
quickInputService
.
quickAccess
.
show
(
prefix
,
options
);
this
.
quickInputService
.
quickAccess
.
show
(
prefix
,
{
quickNavigateConfiguration
:
options
?.
quickNavigateConfiguration
,
itemActivation
:
(()
=>
{
if
(
options
?.
autoFocus
?.
autoFocusSecondEntry
)
{
return
ItemActivation
.
SECOND
;
}
if
(
options
?.
autoFocus
?.
autoFocusLastEntry
)
{
return
ItemActivation
.
LAST
;
}
return
undefined
;
})()
});
return
Promise
.
resolve
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录