Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7fab6bf6
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,发现更多精彩内容 >>
提交
7fab6bf6
编写于
2月 06, 2020
作者:
C
Christof Marti
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move QuickInput to base layer (#69955)
上级
db7795ff
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
313 addition
and
0 deletion
+313
-0
src/vs/platform/quickinput/common/quickInput.ts
src/vs/platform/quickinput/common/quickInput.ts
+48
-0
src/vs/workbench/browser/parts/quickinput/quickInput.ts
src/vs/workbench/browser/parts/quickinput/quickInput.ts
+265
-0
未找到文件。
src/vs/platform/quickinput/common/quickInput.ts
0 → 100644
浏览文件 @
7fab6bf6
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
IQuickPickItem
,
IPickOptions
,
IInputOptions
,
IQuickNavigateConfiguration
,
IQuickPick
,
IQuickInputButton
,
IInputBox
,
QuickPickInput
}
from
'
vs/base/parts/quickinput/common/quickInput
'
;
export
{
IQuickPickItem
,
IPickOptions
,
IInputOptions
,
IQuickNavigateConfiguration
,
IQuickPick
,
IQuickInput
,
IQuickInputButton
,
IInputBox
,
IQuickPickItemButtonEvent
,
QuickPickInput
,
IQuickPickSeparator
,
IKeyMods
}
from
'
vs/base/parts/quickinput/common/quickInput
'
;
export
const
IQuickInputService
=
createDecorator
<
IQuickInputService
>
(
'
quickInputService
'
);
export
type
Omit
<
T
,
K
extends
keyof
T
>
=
Pick
<
T
,
Exclude
<
keyof
T
,
K
>>
;
export
interface
IQuickInputService
{
_serviceBrand
:
undefined
;
/**
* Opens the quick input box for selecting items and returns a promise with the user selected item(s) if any.
*/
pick
<
T
extends
IQuickPickItem
>
(
picks
:
Promise
<
QuickPickInput
<
T
>
[]
>
|
QuickPickInput
<
T
>
[],
options
?:
IPickOptions
<
T
>
&
{
canPickMany
:
true
},
token
?:
CancellationToken
):
Promise
<
T
[]
>
;
pick
<
T
extends
IQuickPickItem
>
(
picks
:
Promise
<
QuickPickInput
<
T
>
[]
>
|
QuickPickInput
<
T
>
[],
options
?:
IPickOptions
<
T
>
&
{
canPickMany
:
false
},
token
?:
CancellationToken
):
Promise
<
T
>
;
pick
<
T
extends
IQuickPickItem
>
(
picks
:
Promise
<
QuickPickInput
<
T
>
[]
>
|
QuickPickInput
<
T
>
[],
options
?:
Omit
<
IPickOptions
<
T
>
,
'
canPickMany
'
>
,
token
?:
CancellationToken
):
Promise
<
T
>
;
/**
* Opens the quick input box for text input and returns a promise with the user typed value if any.
*/
input
(
options
?:
IInputOptions
,
token
?:
CancellationToken
):
Promise
<
string
>
;
backButton
:
IQuickInputButton
;
createQuickPick
<
T
extends
IQuickPickItem
>
():
IQuickPick
<
T
>
;
createInputBox
():
IInputBox
;
focus
():
void
;
toggle
():
void
;
navigate
(
next
:
boolean
,
quickNavigate
?:
IQuickNavigateConfiguration
):
void
;
accept
():
Promise
<
void
>
;
back
():
Promise
<
void
>
;
cancel
():
Promise
<
void
>
;
}
src/vs/workbench/browser/parts/quickinput/quickInput.ts
0 → 100644
浏览文件 @
7fab6bf6
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Component
}
from
'
vs/workbench/common/component
'
;
import
{
IQuickInputService
,
IQuickPickItem
,
IPickOptions
,
IInputOptions
,
IQuickNavigateConfiguration
,
IQuickPick
,
IQuickInputButton
,
IInputBox
,
QuickPickInput
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
IWorkbenchLayoutService
}
from
'
vs/workbench/services/layout/browser/layoutService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
inputBackground
,
inputForeground
,
inputBorder
,
inputValidationInfoBackground
,
inputValidationInfoForeground
,
inputValidationInfoBorder
,
inputValidationWarningBackground
,
inputValidationWarningForeground
,
inputValidationWarningBorder
,
inputValidationErrorBackground
,
inputValidationErrorForeground
,
inputValidationErrorBorder
,
badgeBackground
,
badgeForeground
,
contrastBorder
,
buttonForeground
,
buttonBackground
,
buttonHoverBackground
,
progressBarBackground
,
widgetShadow
,
listFocusForeground
,
listFocusBackground
,
activeContrastBorder
,
pickerGroupBorder
,
pickerGroupForeground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
QUICK_INPUT_BACKGROUND
,
QUICK_INPUT_FOREGROUND
}
from
'
vs/workbench/common/theme
'
;
import
{
IQuickOpenService
}
from
'
vs/platform/quickOpen/common/quickOpen
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
CLOSE_ON_FOCUS_LOST_CONFIG
}
from
'
vs/workbench/browser/quickopen
'
;
import
{
computeStyles
}
from
'
vs/platform/theme/common/styler
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
IContextKeyService
,
RawContextKey
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ICommandAndKeybindingRule
,
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
inQuickOpenContext
,
InQuickOpenContextKey
}
from
'
vs/workbench/browser/parts/quickopen/quickopen
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IAccessibilityService
}
from
'
vs/platform/accessibility/common/accessibility
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
QuickInputController
,
IQuickInputStyles
}
from
'
vs/base/parts/quickinput/browser/quickInput
'
;
import
{
WorkbenchList
}
from
'
vs/platform/list/browser/listService
'
;
import
{
List
,
IListOptions
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
{
IListVirtualDelegate
,
IListRenderer
}
from
'
vs/base/browser/ui/list/list
'
;
export
class
QuickInputService
extends
Component
implements
IQuickInputService
{
public
_serviceBrand
:
undefined
;
public
backButton
:
IQuickInputButton
;
private
static
readonly
ID
=
'
workbench.component.quickinput
'
;
private
inQuickOpenWidgets
:
Record
<
string
,
boolean
>
=
{};
private
inQuickOpenContext
:
IContextKey
<
boolean
>
;
private
contexts
:
Map
<
string
,
IContextKey
<
boolean
>>
=
new
Map
();
private
controller
:
QuickInputController
;
constructor
(
@
IEnvironmentService
private
readonly
environmentService
:
IEnvironmentService
,
@
IConfigurationService
private
readonly
configurationService
:
IConfigurationService
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
@
IQuickOpenService
private
readonly
quickOpenService
:
IQuickOpenService
,
@
IEditorGroupsService
private
readonly
editorGroupService
:
IEditorGroupsService
,
@
IKeybindingService
private
readonly
keybindingService
:
IKeybindingService
,
@
IContextKeyService
private
readonly
contextKeyService
:
IContextKeyService
,
@
IThemeService
themeService
:
IThemeService
,
@
IStorageService
storageService
:
IStorageService
,
@
IAccessibilityService
private
readonly
accessibilityService
:
IAccessibilityService
,
@
IWorkbenchLayoutService
private
readonly
layoutService
:
IWorkbenchLayoutService
)
{
super
(
QuickInputService
.
ID
,
themeService
,
storageService
);
this
.
inQuickOpenContext
=
InQuickOpenContextKey
.
bindTo
(
contextKeyService
);
this
.
_register
(
this
.
quickOpenService
.
onShow
(()
=>
this
.
inQuickOpen
(
'
quickOpen
'
,
true
)));
this
.
_register
(
this
.
quickOpenService
.
onHide
(()
=>
this
.
inQuickOpen
(
'
quickOpen
'
,
false
)));
this
.
controller
=
new
QuickInputController
({
idPrefix
:
'
quickInput_
'
,
// Constant since there is still only one.
container
:
this
.
layoutService
.
getWorkbenchElement
(),
ignoreFocusOut
:
()
=>
this
.
environmentService
.
args
[
'
sticky-quickopen
'
]
||
!
this
.
configurationService
.
getValue
(
CLOSE_ON_FOCUS_LOST_CONFIG
),
isScreenReaderOptimized
:
()
=>
this
.
accessibilityService
.
isScreenReaderOptimized
(),
backKeybindingLabel
:
()
=>
this
.
keybindingService
.
lookupKeybinding
(
QuickPickBack
.
id
)?.
getLabel
()
||
undefined
,
setContextKey
:
(
id
?:
string
)
=>
this
.
setContextKey
(
id
),
returnFocus
:
()
=>
this
.
editorGroupService
.
activeGroup
.
focus
(),
createList
:
<
T
>
(
user
:
string
,
container
:
HTMLElement
,
delegate
:
IListVirtualDelegate
<
T
>
,
renderers
:
IListRenderer
<
T
,
any
>
[],
options
:
IListOptions
<
T
>
,
)
=>
this
.
instantiationService
.
createInstance
(
WorkbenchList
,
user
,
container
,
delegate
,
renderers
,
options
)
as
List
<
T
>
,
styles
:
this
.
computeStyles
(),
});
this
.
backButton
=
this
.
controller
.
backButton
;
this
.
_register
(
this
.
layoutService
.
onLayout
(
dimension
=>
this
.
controller
.
layout
(
dimension
,
this
.
layoutService
.
getTitleBarOffset
())));
this
.
controller
.
layout
(
this
.
layoutService
.
dimension
,
this
.
layoutService
.
getTitleBarOffset
());
this
.
_register
(
this
.
quickOpenService
.
onShow
(()
=>
this
.
controller
.
hide
(
true
)));
this
.
_register
(
this
.
controller
.
onShow
(()
=>
{
this
.
quickOpenService
.
close
();
this
.
inQuickOpen
(
'
quickInput
'
,
true
);
this
.
resetContextKeys
();
}));
this
.
_register
(
this
.
controller
.
onHide
(()
=>
{
this
.
inQuickOpen
(
'
quickInput
'
,
false
);
this
.
resetContextKeys
();
}));
}
private
inQuickOpen
(
widget
:
'
quickInput
'
|
'
quickOpen
'
,
open
:
boolean
)
{
if
(
open
)
{
this
.
inQuickOpenWidgets
[
widget
]
=
true
;
}
else
{
delete
this
.
inQuickOpenWidgets
[
widget
];
}
if
(
Object
.
keys
(
this
.
inQuickOpenWidgets
).
length
)
{
if
(
!
this
.
inQuickOpenContext
.
get
())
{
this
.
inQuickOpenContext
.
set
(
true
);
}
}
else
{
if
(
this
.
inQuickOpenContext
.
get
())
{
this
.
inQuickOpenContext
.
reset
();
}
}
}
private
setContextKey
(
id
?:
string
)
{
let
key
:
IContextKey
<
boolean
>
|
undefined
;
if
(
id
)
{
key
=
this
.
contexts
.
get
(
id
);
if
(
!
key
)
{
key
=
new
RawContextKey
<
boolean
>
(
id
,
false
)
.
bindTo
(
this
.
contextKeyService
);
this
.
contexts
.
set
(
id
,
key
);
}
}
if
(
key
&&
key
.
get
())
{
return
;
// already active context
}
this
.
resetContextKeys
();
if
(
key
)
{
key
.
set
(
true
);
}
}
private
resetContextKeys
()
{
this
.
contexts
.
forEach
(
context
=>
{
if
(
context
.
get
())
{
context
.
reset
();
}
});
}
pick
<
T
extends
IQuickPickItem
,
O
extends
IPickOptions
<
T
>>
(
picks
:
Promise
<
QuickPickInput
<
T
>
[]
>
|
QuickPickInput
<
T
>
[],
options
:
O
=
<
O
>
{},
token
:
CancellationToken
=
CancellationToken
.
None
):
Promise
<
O
extends
{
canPickMany
:
true
}
?
T
[]
:
T
>
{
return
this
.
controller
.
pick
(
picks
,
options
,
token
);
}
input
(
options
:
IInputOptions
=
{},
token
:
CancellationToken
=
CancellationToken
.
None
):
Promise
<
string
>
{
return
this
.
controller
.
input
(
options
,
token
);
}
createQuickPick
<
T
extends
IQuickPickItem
>
():
IQuickPick
<
T
>
{
return
this
.
controller
.
createQuickPick
();
}
createInputBox
():
IInputBox
{
return
this
.
controller
.
createInputBox
();
}
focus
()
{
this
.
controller
.
focus
();
}
toggle
()
{
this
.
controller
.
toggle
();
}
navigate
(
next
:
boolean
,
quickNavigate
?:
IQuickNavigateConfiguration
)
{
this
.
controller
.
navigate
(
next
,
quickNavigate
);
}
accept
()
{
return
this
.
controller
.
accept
();
}
back
()
{
return
this
.
controller
.
back
();
}
cancel
()
{
return
this
.
controller
.
cancel
();
}
protected
updateStyles
()
{
this
.
controller
.
applyStyles
(
this
.
computeStyles
());
}
private
computeStyles
():
IQuickInputStyles
{
return
{
widget
:
{
titleColor
:
{
dark
:
'
rgba(255, 255, 255, 0.105)
'
,
light
:
'
rgba(0,0,0,.06)
'
,
hc
:
'
black
'
}[
this
.
theme
.
type
],
// TODO
...
computeStyles
(
this
.
theme
,
{
quickInputBackground
:
QUICK_INPUT_BACKGROUND
,
quickInputForeground
:
QUICK_INPUT_FOREGROUND
,
contrastBorder
,
widgetShadow
,
}),
},
inputBox
:
computeStyles
(
this
.
theme
,
{
inputForeground
,
inputBackground
,
inputBorder
,
inputValidationInfoBackground
,
inputValidationInfoForeground
,
inputValidationInfoBorder
,
inputValidationWarningBackground
,
inputValidationWarningForeground
,
inputValidationWarningBorder
,
inputValidationErrorBackground
,
inputValidationErrorForeground
,
inputValidationErrorBorder
,
}),
countBadge
:
computeStyles
(
this
.
theme
,
{
badgeBackground
,
badgeForeground
,
badgeBorder
:
contrastBorder
}),
button
:
computeStyles
(
this
.
theme
,
{
buttonForeground
,
buttonBackground
,
buttonHoverBackground
,
buttonBorder
:
contrastBorder
}),
progressBar
:
computeStyles
(
this
.
theme
,
{
progressBarBackground
}),
list
:
computeStyles
(
this
.
theme
,
{
listBackground
:
QUICK_INPUT_BACKGROUND
,
// Look like focused when inactive.
listInactiveFocusForeground
:
listFocusForeground
,
listInactiveFocusBackground
:
listFocusBackground
,
listFocusOutline
:
activeContrastBorder
,
listInactiveFocusOutline
:
activeContrastBorder
,
pickerGroupBorder
,
pickerGroupForeground
,
}),
};
}
}
export
const
QuickPickManyToggle
:
ICommandAndKeybindingRule
=
{
id
:
'
workbench.action.quickPickManyToggle
'
,
weight
:
KeybindingWeight
.
WorkbenchContrib
,
when
:
inQuickOpenContext
,
primary
:
0
,
handler
:
accessor
=>
{
const
quickInputService
=
accessor
.
get
(
IQuickInputService
);
quickInputService
.
toggle
();
}
};
export
const
QuickPickBack
:
ICommandAndKeybindingRule
=
{
id
:
'
workbench.action.quickInputBack
'
,
weight
:
KeybindingWeight
.
WorkbenchContrib
+
50
,
when
:
inQuickOpenContext
,
primary
:
0
,
win
:
{
primary
:
KeyMod
.
Alt
|
KeyCode
.
LeftArrow
},
mac
:
{
primary
:
KeyMod
.
WinCtrl
|
KeyCode
.
US_MINUS
},
linux
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Alt
|
KeyCode
.
US_MINUS
},
handler
:
accessor
=>
{
const
quickInputService
=
accessor
.
get
(
IQuickInputService
);
quickInputService
.
back
();
}
};
registerSingleton
(
IQuickInputService
,
QuickInputService
,
true
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录