Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
7edc0a4e
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,发现更多精彩内容 >>
提交
7edc0a4e
编写于
3月 09, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quick access - implement view handler
上级
de2426aa
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
232 addition
and
6 deletion
+232
-6
src/vs/base/parts/quickinput/browser/quickInputList.ts
src/vs/base/parts/quickinput/browser/quickInputList.ts
+9
-3
src/vs/base/parts/quickinput/common/quickInput.ts
src/vs/base/parts/quickinput/common/quickInput.ts
+9
-1
src/vs/editor/contrib/quickAccess/gotoLine.ts
src/vs/editor/contrib/quickAccess/gotoLine.ts
+2
-2
src/vs/workbench/contrib/quickaccess/browser/quickAccess.contribution.ts
...h/contrib/quickaccess/browser/quickAccess.contribution.ts
+7
-0
src/vs/workbench/contrib/quickaccess/browser/viewQuickAccess.ts
.../workbench/contrib/quickaccess/browser/viewQuickAccess.ts
+205
-0
未找到文件。
src/vs/base/parts/quickinput/browser/quickInputList.ts
浏览文件 @
7edc0a4e
...
...
@@ -33,9 +33,12 @@ interface IListElement {
readonly
index
:
number
;
readonly
item
:
IQuickPickItem
;
readonly
saneLabel
:
string
;
readonly
saneAriaLabel
:
string
;
readonly
saneDescription
?:
string
;
readonly
saneDetail
?:
string
;
readonly
saneAriaLabel
:
string
;
readonly
labelHighlights
?:
IMatch
[];
readonly
descriptionHighlights
?:
IMatch
[];
readonly
detailHighlights
?:
IMatch
[];
readonly
checked
:
boolean
;
readonly
separator
?:
IQuickPickSeparator
;
readonly
fireButtonTriggered
:
(
event
:
IQuickPickItemButtonEvent
<
IQuickPickItem
>
)
=>
void
;
...
...
@@ -45,9 +48,9 @@ class ListElement implements IListElement {
index
!
:
number
;
item
!
:
IQuickPickItem
;
saneLabel
!
:
string
;
saneAriaLabel
!
:
string
;
saneDescription
?:
string
;
saneDetail
?:
string
;
saneAriaLabel
!
:
string
;
hidden
=
false
;
private
readonly
_onChecked
=
new
Emitter
<
boolean
>
();
onChecked
=
this
.
_onChecked
.
event
;
...
...
@@ -375,9 +378,12 @@ export class QuickInputList {
index
,
item
,
saneLabel
,
saneAriaLabel
,
saneDescription
,
saneDetail
,
saneAriaLabel
,
labelHighlights
:
item
.
highlights
?.
label
,
descriptionHighlights
:
item
.
highlights
?.
description
,
detailHighlights
:
item
.
highlights
?.
detail
,
checked
:
false
,
separator
:
previous
&&
previous
.
type
===
'
separator
'
?
previous
:
undefined
,
fireButtonTriggered
...
...
src/vs/base/parts/quickinput/common/quickInput.ts
浏览文件 @
7edc0a4e
...
...
@@ -7,15 +7,23 @@ import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IMatch
}
from
'
vs/base/common/filters
'
;
export
interface
IQuickPickItemHighlights
{
label
?:
IMatch
[];
description
?:
IMatch
[];
detail
?:
IMatch
[];
}
export
interface
IQuickPickItem
{
type
?:
'
item
'
;
id
?:
string
;
label
:
string
;
ariaLabel
?:
string
;
description
?:
string
;
detail
?:
string
;
ariaLabel
?:
string
;
iconClasses
?:
string
[];
highlights
?:
IQuickPickItemHighlights
;
buttons
?:
IQuickInputButton
[];
picked
?:
boolean
;
alwaysShow
?:
boolean
;
...
...
src/vs/editor/contrib/quickAccess/gotoLine.ts
浏览文件 @
7edc0a4e
...
...
@@ -25,8 +25,8 @@ export abstract class AbstractGotoLineQuickAccessProvider extends AbstractEditor
provide
(
picker
:
IQuickPick
<
IGotoLineQuickPickItem
>
,
token
:
CancellationToken
):
IDisposable
{
const
disposables
=
new
DisposableStore
();
// Disable filtering, we control the results
picker
.
filterValue
=
()
=>
''
;
// Disable filtering
& sorting
, we control the results
picker
.
matchOnLabel
=
picker
.
matchOnDescription
=
picker
.
matchOnDetail
=
picker
.
sortByLabel
=
false
;
// Provide based on current active editor
let
pickerDisposable
=
this
.
doProvide
(
picker
,
token
);
...
...
src/vs/workbench/contrib/quickaccess/browser/quickAccess.contribution.ts
浏览文件 @
7edc0a4e
...
...
@@ -7,9 +7,16 @@ import { localize } from 'vs/nls';
import
{
IQuickAccessRegistry
,
Extensions
}
from
'
vs/platform/quickinput/common/quickAccess
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
HelpQuickAccessProvider
}
from
'
vs/platform/quickinput/browser/helpQuickAccess
'
;
import
{
ViewQuickAccessProvider
,
VIEW_QUICK_ACCESS_PREFIX
}
from
'
vs/workbench/contrib/quickaccess/browser/viewQuickAccess
'
;
Registry
.
as
<
IQuickAccessRegistry
>
(
Extensions
.
Quickaccess
).
registerQuickAccessProvider
({
ctor
:
HelpQuickAccessProvider
,
prefix
:
'
?
'
,
helpEntries
:
[{
description
:
localize
(
'
helpQuickAccess
'
,
"
Show all Quick Access Providers
"
),
needsEditor
:
false
}]
});
Registry
.
as
<
IQuickAccessRegistry
>
(
Extensions
.
Quickaccess
).
registerQuickAccessProvider
({
ctor
:
ViewQuickAccessProvider
,
prefix
:
VIEW_QUICK_ACCESS_PREFIX
,
helpEntries
:
[{
description
:
localize
(
'
viewQuickAccess
'
,
"
Open View
"
),
needsEditor
:
false
}]
});
src/vs/workbench/contrib/quickaccess/browser/viewQuickAccess.ts
0 → 100644
浏览文件 @
7edc0a4e
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
localize
}
from
'
vs/nls
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
IQuickPick
,
IQuickPickItem
,
IQuickPickSeparator
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
DisposableStore
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IQuickAccessProvider
}
from
'
vs/platform/quickinput/common/quickAccess
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
import
{
IViewDescriptorService
,
IViewsService
,
ViewContainer
,
IViewsRegistry
,
Extensions
as
ViewExtensions
,
IViewContainersRegistry
}
from
'
vs/workbench/common/views
'
;
import
{
IOutputService
}
from
'
vs/workbench/contrib/output/common/output
'
;
import
{
ITerminalService
}
from
'
vs/workbench/contrib/terminal/browser/terminal
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ViewletDescriptor
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
matchesFuzzy
}
from
'
vs/base/common/filters
'
;
import
{
fuzzyContains
}
from
'
vs/base/common/strings
'
;
import
{
withNullAsUndefined
}
from
'
vs/base/common/types
'
;
export
const
VIEW_QUICK_ACCESS_PREFIX
=
'
view
'
;
interface
IViewQuickPickItem
extends
IQuickPickItem
{
containerLabel
:
string
;
run
:
()
=>
Promise
<
unknown
>
;
}
export
class
ViewQuickAccessProvider
implements
IQuickAccessProvider
{
constructor
(
@
IViewletService
private
readonly
viewletService
:
IViewletService
,
@
IViewDescriptorService
private
readonly
viewDescriptorService
:
IViewDescriptorService
,
@
IViewsService
private
readonly
viewsService
:
IViewsService
,
@
IOutputService
private
readonly
outputService
:
IOutputService
,
@
ITerminalService
private
readonly
terminalService
:
ITerminalService
,
@
IPanelService
private
readonly
panelService
:
IPanelService
,
@
IContextKeyService
private
readonly
contextKeyService
:
IContextKeyService
,
)
{
}
provide
(
picker
:
IQuickPick
<
IViewQuickPickItem
>
,
token
:
CancellationToken
):
IDisposable
{
const
disposables
=
new
DisposableStore
();
// Disable filtering & sorting, we control the results
picker
.
matchOnLabel
=
picker
.
matchOnDescription
=
picker
.
matchOnDetail
=
picker
.
sortByLabel
=
false
;
// Add all view items
picker
.
items
=
this
.
getViewPickItems
(
''
);
// Filter on type
disposables
.
add
(
picker
.
onDidChangeValue
(
value
=>
{
picker
.
items
=
this
.
getViewPickItems
(
value
.
trim
().
substr
(
VIEW_QUICK_ACCESS_PREFIX
.
length
));
}));
// Open the picked view on accept
disposables
.
add
(
picker
.
onDidAccept
(()
=>
{
const
[
item
]
=
picker
.
selectedItems
;
if
(
item
)
{
picker
.
hide
();
item
.
run
();
}
}));
return
disposables
;
}
private
getViewPickItems
(
filter
:
string
):
Array
<
IViewQuickPickItem
|
IQuickPickSeparator
>
{
const
filteredViewEntries
=
this
.
doGetViewPickItems
().
filter
(
entry
=>
{
if
(
!
filter
)
{
return
true
;
}
// Match fuzzy on label
entry
.
highlights
=
{
label
:
withNullAsUndefined
(
matchesFuzzy
(
filter
,
entry
.
label
,
true
))
};
// Return if we have a match on label or container
return
entry
.
highlights
.
label
||
fuzzyContains
(
entry
.
containerLabel
,
filter
);
});
// Map entries to container labels
const
mapEntryToContainer
=
new
Map
<
string
,
string
>
();
for
(
const
entry
of
filteredViewEntries
)
{
if
(
!
mapEntryToContainer
.
has
(
entry
.
label
))
{
mapEntryToContainer
.
set
(
entry
.
label
,
entry
.
containerLabel
);
}
}
const
filteredViewEntriesWithSeparators
:
Array
<
IViewQuickPickItem
|
IQuickPickSeparator
>
=
[];
// Add separators for containers
let
lastContainer
:
string
|
undefined
=
undefined
;
for
(
const
entry
of
filteredViewEntries
)
{
if
(
lastContainer
!==
entry
.
containerLabel
)
{
lastContainer
=
entry
.
containerLabel
;
// When the entry container has a parent container, set container
// label as Parent / Child. For example, `Views / Explorer`.
let
separatorLabel
:
string
;
if
(
mapEntryToContainer
.
has
(
lastContainer
))
{
separatorLabel
=
`
${
mapEntryToContainer
.
get
(
lastContainer
)}
/
${
lastContainer
}
`
;
}
else
{
separatorLabel
=
lastContainer
;
}
filteredViewEntriesWithSeparators
.
push
({
type
:
'
separator
'
,
label
:
separatorLabel
});
}
filteredViewEntriesWithSeparators
.
push
(
entry
);
}
return
filteredViewEntriesWithSeparators
;
}
private
doGetViewPickItems
():
Array
<
IViewQuickPickItem
>
{
const
viewEntries
:
Array
<
IViewQuickPickItem
>
=
[];
const
getViewEntriesForViewlet
=
(
viewlet
:
ViewletDescriptor
,
viewContainer
:
ViewContainer
):
IViewQuickPickItem
[]
=>
{
const
views
=
Registry
.
as
<
IViewsRegistry
>
(
ViewExtensions
.
ViewsRegistry
).
getViews
(
viewContainer
);
const
result
:
IViewQuickPickItem
[]
=
[];
for
(
const
view
of
views
)
{
if
(
this
.
contextKeyService
.
contextMatchesRules
(
view
.
when
))
{
result
.
push
({
label
:
view
.
name
,
containerLabel
:
viewlet
.
name
,
run
:
()
=>
this
.
viewsService
.
openView
(
view
.
id
,
true
)
});
}
}
return
result
;
};
// Viewlets
const
viewlets
=
this
.
viewletService
.
getViewlets
();
for
(
const
viewlet
of
viewlets
)
{
if
(
this
.
includeViewlet
(
viewlet
))
{
viewEntries
.
push
({
label
:
viewlet
.
name
,
containerLabel
:
localize
(
'
views
'
,
"
Side Bar
"
),
run
:
()
=>
this
.
viewletService
.
openViewlet
(
viewlet
.
id
,
true
)
});
}
}
// Panels
const
panels
=
this
.
panelService
.
getPanels
();
for
(
const
panel
of
panels
)
{
viewEntries
.
push
({
label
:
panel
.
name
,
containerLabel
:
localize
(
'
panels
'
,
"
Panel
"
),
run
:
()
=>
this
.
panelService
.
openPanel
(
panel
.
id
,
true
)
});
}
// Viewlet Views
for
(
const
viewlet
of
viewlets
)
{
const
viewContainer
=
Registry
.
as
<
IViewContainersRegistry
>
(
ViewExtensions
.
ViewContainersRegistry
).
get
(
viewlet
.
id
);
if
(
viewContainer
)
{
viewEntries
.
push
(...
getViewEntriesForViewlet
(
viewlet
,
viewContainer
));
}
}
// Terminals
this
.
terminalService
.
terminalTabs
.
forEach
((
tab
,
tabIndex
)
=>
{
tab
.
terminalInstances
.
forEach
((
terminal
,
terminalIndex
)
=>
{
viewEntries
.
push
({
label
:
localize
(
'
terminalTitle
'
,
"
{0}: {1}
"
,
`
${
tabIndex
+
1
}
.
${
terminalIndex
+
1
}
`
,
terminal
.
title
),
containerLabel
:
localize
(
'
terminals
'
,
"
Terminal
"
),
run
:
async
()
=>
{
await
this
.
terminalService
.
showPanel
(
true
);
return
this
.
terminalService
.
setActiveInstance
(
terminal
);
}
});
});
});
// Output Channels
const
channels
=
this
.
outputService
.
getChannelDescriptors
();
for
(
const
channel
of
channels
)
{
viewEntries
.
push
({
label
:
channel
.
log
?
localize
(
'
logChannel
'
,
"
Log ({0})
"
,
channel
.
label
)
:
channel
.
label
,
containerLabel
:
localize
(
'
channels
'
,
"
Output
"
),
run
:
()
=>
this
.
outputService
.
showChannel
(
channel
.
id
)
});
}
// Add generic ARIA label
viewEntries
.
forEach
(
entry
=>
entry
.
ariaLabel
=
localize
(
'
entryAriaLabel
'
,
"
{0}, view picker
"
,
entry
.
label
));
return
viewEntries
;
}
private
includeViewlet
(
viewlet
:
ViewletDescriptor
):
boolean
{
const
viewContainer
=
Registry
.
as
<
IViewContainersRegistry
>
(
ViewExtensions
.
ViewContainersRegistry
).
get
(
viewlet
.
id
);
if
(
viewContainer
?.
hideIfEmpty
)
{
return
this
.
viewDescriptorService
.
getViewDescriptors
(
viewContainer
).
activeViewDescriptors
.
length
>
0
;
}
return
true
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录