Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
06595436
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,发现更多精彩内容 >>
提交
06595436
编写于
8月 07, 2018
作者:
C
Christof Marti
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add contextKey (#29096)
上级
dcd17d8b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
1 deletion
+55
-1
src/vs/platform/quickinput/common/quickInput.ts
src/vs/platform/quickinput/common/quickInput.ts
+7
-0
src/vs/workbench/browser/parts/quickinput/quickInput.ts
src/vs/workbench/browser/parts/quickinput/quickInput.ts
+48
-1
未找到文件。
src/vs/platform/quickinput/common/quickInput.ts
浏览文件 @
06595436
...
...
@@ -51,6 +51,11 @@ export interface IPickOptions<T extends IQuickPickItem> {
*/
canPickMany
?:
boolean
;
/**
* a context key to set when this picker is active
*/
contextKey
?:
string
;
/**
* an optional property for the item to focus initially.
*/
...
...
@@ -104,6 +109,8 @@ export interface IQuickInput {
enabled
:
boolean
;
contextKey
:
string
|
undefined
;
busy
:
boolean
;
ignoreFocusOut
:
boolean
;
...
...
src/vs/workbench/browser/parts/quickinput/quickInput.ts
浏览文件 @
06595436
...
...
@@ -73,6 +73,7 @@ interface QuickInputUI {
show
(
controller
:
QuickInput
):
void
;
setVisibilities
(
visibilities
:
Visibilities
):
void
;
setEnabled
(
enabled
:
boolean
):
void
;
setContextKey
(
contextKey
?:
string
):
void
;
hide
():
void
;
}
...
...
@@ -94,6 +95,7 @@ class QuickInput implements IQuickInput {
private
_totalSteps
:
number
;
protected
visible
=
false
;
private
_enabled
=
true
;
private
_contextKey
:
string
;
private
_busy
=
false
;
private
_ignoreFocusOut
=
false
;
private
_buttons
:
IQuickInputButton
[]
=
[];
...
...
@@ -148,6 +150,15 @@ class QuickInput implements IQuickInput {
this
.
update
();
}
get
contextKey
()
{
return
this
.
_contextKey
;
}
set
contextKey
(
contextKey
:
string
)
{
this
.
_contextKey
=
contextKey
;
this
.
update
();
}
get
busy
()
{
return
this
.
_busy
;
}
...
...
@@ -249,6 +260,7 @@ class QuickInput implements IQuickInput {
}
this
.
ui
.
ignoreFocusOut
=
this
.
ignoreFocusOut
;
this
.
ui
.
setEnabled
(
this
.
enabled
);
this
.
ui
.
setContextKey
(
this
.
contextKey
);
}
private
getTitle
()
{
...
...
@@ -740,6 +752,7 @@ export class QuickInputService extends Component implements IQuickInputService {
private
enabled
=
true
;
private
inQuickOpenWidgets
:
Record
<
string
,
boolean
>
=
{};
private
inQuickOpenContext
:
IContextKey
<
boolean
>
;
private
contexts
:
{
[
id
:
string
]:
IContextKey
<
boolean
>
;
}
=
Object
.
create
(
null
);
private
onDidAcceptEmitter
=
this
.
_register
(
new
Emitter
<
void
>
());
private
onDidTriggerButtonEmitter
=
this
.
_register
(
new
Emitter
<
IQuickInputButton
>
());
...
...
@@ -753,7 +766,7 @@ export class QuickInputService extends Component implements IQuickInputService {
@
IQuickOpenService
private
quickOpenService
:
IQuickOpenService
,
@
IEditorGroupsService
private
editorGroupService
:
IEditorGroupsService
,
@
IKeybindingService
private
keybindingService
:
IKeybindingService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IContextKeyService
private
contextKeyService
:
IContextKeyService
,
@
IThemeService
themeService
:
IThemeService
)
{
super
(
QuickInputService
.
ID
,
themeService
);
...
...
@@ -779,6 +792,36 @@ export class QuickInputService extends Component implements IQuickInputService {
}
}
private
setContextKey
(
id
?:
string
)
{
let
key
:
IContextKey
<
boolean
>
;
if
(
id
)
{
key
=
this
.
contexts
[
id
];
if
(
!
key
)
{
key
=
new
RawContextKey
<
boolean
>
(
id
,
false
)
.
bindTo
(
this
.
contextKeyService
);
this
.
contexts
[
id
]
=
key
;
}
}
if
(
key
&&
key
.
get
())
{
return
;
// already active context
}
this
.
resetContextKeys
();
if
(
key
)
{
key
.
set
(
true
);
}
}
private
resetContextKeys
()
{
for
(
const
key
in
this
.
contexts
)
{
if
(
this
.
contexts
[
key
].
get
())
{
this
.
contexts
[
key
].
reset
();
}
}
}
private
create
()
{
if
(
this
.
ui
)
{
return
;
...
...
@@ -923,6 +966,7 @@ export class QuickInputService extends Component implements IQuickInputService {
hide
:
()
=>
this
.
hide
(),
setVisibilities
:
visibilities
=>
this
.
setVisibilities
(
visibilities
),
setEnabled
:
enabled
=>
this
.
setEnabled
(
enabled
),
setContextKey
:
contextKey
=>
this
.
setContextKey
(
contextKey
),
};
this
.
updateStyles
();
}
...
...
@@ -976,6 +1020,7 @@ export class QuickInputService extends Component implements IQuickInputService {
input
.
ignoreFocusOut
=
options
.
ignoreFocusLost
;
input
.
matchOnDescription
=
options
.
matchOnDescription
;
input
.
matchOnDetail
=
options
.
matchOnDetail
;
input
.
contextKey
=
options
.
contextKey
;
input
.
busy
=
true
;
TPromise
.
join
([
picks
,
options
.
activeItem
])
.
then
(([
items
,
activeItem
])
=>
{
...
...
@@ -1096,6 +1141,7 @@ export class QuickInputService extends Component implements IQuickInputService {
backButton
.
tooltip
=
keybinding
?
localize
(
'
quickInput.backWithKeybinding
'
,
"
Back ({0})
"
,
keybinding
.
getLabel
())
:
localize
(
'
quickInput.back
'
,
"
Back
"
);
this
.
inQuickOpen
(
'
quickInput
'
,
true
);
this
.
resetContextKeys
();
this
.
ui
.
container
.
style
.
display
=
''
;
this
.
updateLayout
();
...
...
@@ -1136,6 +1182,7 @@ export class QuickInputService extends Component implements IQuickInputService {
if
(
controller
)
{
this
.
controller
=
null
;
this
.
inQuickOpen
(
'
quickInput
'
,
false
);
this
.
resetContextKeys
();
this
.
ui
.
container
.
style
.
display
=
'
none
'
;
if
(
!
focusLost
)
{
this
.
editorGroupService
.
activeGroup
.
focus
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录