Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
65d5eb56
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
65d5eb56
编写于
3月 21, 2018
作者:
C
Christof Marti
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Label, description, detail (#45589)
上级
60729e01
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
103 addition
and
30 deletion
+103
-30
src/vs/workbench/api/electron-browser/mainThreadQuickOpen.ts
src/vs/workbench/api/electron-browser/mainThreadQuickOpen.ts
+3
-1
src/vs/workbench/browser/parts/quickinput/quickInput.css
src/vs/workbench/browser/parts/quickinput/quickInput.css
+44
-1
src/vs/workbench/browser/parts/quickinput/quickInput.ts
src/vs/workbench/browser/parts/quickinput/quickInput.ts
+9
-3
src/vs/workbench/browser/parts/quickinput/quickInputBox.ts
src/vs/workbench/browser/parts/quickinput/quickInputBox.ts
+5
-1
src/vs/workbench/browser/parts/quickinput/quickInputCheckboxList.ts
...kbench/browser/parts/quickinput/quickInputCheckboxList.ts
+42
-24
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadQuickOpen.ts
浏览文件 @
65d5eb56
...
...
@@ -17,6 +17,7 @@ export class MainThreadQuickOpen implements MainThreadQuickOpenShape {
private
_proxy
:
ExtHostQuickOpenShape
;
private
_quickOpenService
:
IQuickOpenService
;
private
_quickInputService
:
IQuickInputService
;
private
_doSetItems
:
(
items
:
MyQuickPickItems
[])
=>
any
;
private
_doSetError
:
(
error
:
Error
)
=>
any
;
private
_contents
:
TPromise
<
MyQuickPickItems
[]
>
;
...
...
@@ -25,10 +26,11 @@ export class MainThreadQuickOpen implements MainThreadQuickOpenShape {
constructor
(
extHostContext
:
IExtHostContext
,
@
IQuickOpenService
quickOpenService
:
IQuickOpenService
,
@
IQuickInputService
private
_
quickInputService
:
IQuickInputService
@
IQuickInputService
quickInputService
:
IQuickInputService
)
{
this
.
_proxy
=
extHostContext
.
getProxy
(
ExtHostContext
.
ExtHostQuickOpen
);
this
.
_quickOpenService
=
quickOpenService
;
this
.
_quickInputService
=
quickInputService
;
}
public
dispose
():
void
{
...
...
src/vs/workbench/browser/parts/quickinput/quickInput.css
浏览文件 @
65d5eb56
...
...
@@ -22,7 +22,7 @@
}
.quick-input-box
.monaco-inputbox
>
.wrapper
>
.input
{
padding-left
:
1
4
px
;
padding-left
:
1
5
px
;
}
.quick-input-action
{
...
...
@@ -37,4 +37,47 @@
.quick-input-checkbox-list
{
margin-left
:
3px
;
line-height
:
22px
;
}
.quick-input-checkbox-list
.quick-input-checkbox-list-entry
{
overflow
:
hidden
;
display
:
flex
;
height
:
100%
;
}
.quick-input-checkbox-list
.quick-input-checkbox-list-label
{
overflow
:
hidden
;
display
:
flex
;
height
:
100%
;
flex
:
1
;
}
.quick-input-checkbox-list
.quick-input-checkbox-list-checkbox
{
align-self
:
center
;
/* margin-top: 5px; */
}
.quick-input-checkbox-list
.quick-input-checkbox-list-rows
{
overflow
:
hidden
;
text-overflow
:
ellipsis
;
display
:
flex
;
flex-direction
:
column
;
height
:
100%
;
flex
:
1
;
margin-left
:
1px
;
}
.quick-input-checkbox-list
.quick-input-checkbox-list-rows
>
.quick-input-checkbox-list-row
{
display
:
flex
;
align-items
:
center
;
}
.quick-input-checkbox-list
.quick-input-checkbox-list-rows
.monaco-highlighted-label
span
{
opacity
:
1
;
}
.quick-input-checkbox-list
.quick-input-checkbox-list-label-meta
{
opacity
:
0.7
;
line-height
:
normal
;
}
src/vs/workbench/browser/parts/quickinput/quickInput.ts
浏览文件 @
65d5eb56
...
...
@@ -23,6 +23,8 @@ import { QuickInputBox } from './quickInputBox';
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
CLOSE_ON_FOCUS_LOST_CONFIG
}
from
'
vs/workbench/browser/quickopen
'
;
const
$
=
dom
.
$
;
...
...
@@ -42,6 +44,7 @@ export class QuickInputService extends Component implements IQuickInputService {
private
resolve
:
(
value
?:
object
[]
|
Thenable
<
object
[]
>
)
=>
void
;
constructor
(
@
IConfigurationService
private
configurationService
:
IConfigurationService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IPartService
private
partService
:
IPartService
,
@
IThemeService
themeService
:
IThemeService
...
...
@@ -63,7 +66,7 @@ export class QuickInputService extends Component implements IQuickInputService {
this
.
inputBox
=
new
QuickInputBox
(
headerContainer
);
this
.
toUnbind
.
push
(
this
.
inputBox
);
this
.
inputBox
.
style
(
this
.
themeService
.
getTheme
());
this
.
inputBox
.
on
Input
(
value
=>
{
this
.
inputBox
.
on
DidChange
(
value
=>
{
this
.
checkboxList
.
filter
(
value
);
});
this
.
toUnbind
.
push
(
this
.
inputBox
.
onKeyDown
(
event
=>
{
...
...
@@ -101,7 +104,9 @@ export class QuickInputService extends Component implements IQuickInputService {
return
;
}
}
if
(
this
.
configurationService
.
getValue
(
CLOSE_ON_FOCUS_LOST_CONFIG
))
{
this
.
close
(
false
);
}
}));
this
.
toUnbind
.
push
(
dom
.
addDisposableListener
(
this
.
container
,
dom
.
EventType
.
KEY_DOWN
,
(
e
:
KeyboardEvent
)
=>
{
const
event
=
new
StandardKeyboardEvent
(
e
);
...
...
@@ -130,9 +135,10 @@ export class QuickInputService extends Component implements IQuickInputService {
async
pick
<
T
extends
IPickOpenEntry
>
(
picks
:
TPromise
<
T
[]
>
,
options
?:
IPickOptions
,
token
?:
CancellationToken
):
TPromise
<
T
[]
>
{
this
.
create
();
if
(
this
.
resolve
)
{
this
.
resolve
(
undefined
);
this
.
resolve
();
}
this
.
inputBox
.
setValue
(
''
);
this
.
inputBox
.
setPlaceholder
(
options
.
placeHolder
||
''
);
// TODO: Progress indication.
this
.
checkboxList
.
setElements
(
await
picks
);
...
...
src/vs/workbench/browser/parts/quickinput/quickInputBox.ts
浏览文件 @
65d5eb56
...
...
@@ -46,10 +46,14 @@ export class QuickInputBox {
});
}
on
Input
(
handler
:
(
event
:
string
)
=>
void
):
IDisposable
{
on
DidChange
(
handler
:
(
event
:
string
)
=>
void
):
IDisposable
{
return
this
.
inputBox
.
onDidChange
(
handler
);
}
setValue
(
value
:
string
)
{
this
.
inputBox
.
value
=
value
;
}
setPlaceholder
(
placeholder
:
string
)
{
this
.
inputBox
.
setPlaceHolder
(
placeholder
);
}
...
...
src/vs/workbench/browser/parts/quickinput/quickInputCheckboxList.ts
浏览文件 @
65d5eb56
...
...
@@ -19,20 +19,20 @@ import { Emitter } from 'vs/base/common/event';
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
IconLabel
,
IIconLabelValueOptions
}
from
'
vs/base/browser/ui/iconLabel/iconLabel
'
;
import
{
HighlightedLabel
}
from
'
vs/base/browser/ui/highlightedlabel/highlightedLabel
'
;
const
$
=
dom
.
$
;
interface
ISelectableElement
{
index
:
number
;
item
:
object
;
label
:
string
;
item
:
IPickOpenEntry
;
selected
:
boolean
;
}
class
SelectableElement
implements
ISelectableElement
{
index
:
number
;
item
:
object
;
label
:
string
;
item
:
IPickOpenEntry
;
shouldAlwaysShow
=
false
;
hidden
=
false
;
private
_onSelected
=
new
Emitter
<
boolean
>
();
...
...
@@ -57,10 +57,10 @@ class SelectableElement implements ISelectableElement {
}
interface
ISelectedElementTemplateData
{
element
:
HTMLElement
;
name
:
HTMLElement
;
checkbox
:
HTMLInputElement
;
context
:
SelectableElement
;
label
:
IconLabel
;
detail
:
HighlightedLabel
;
element
:
SelectableElement
;
toDisposeElement
:
IDisposable
[];
toDisposeTemplate
:
IDisposable
[];
}
...
...
@@ -75,30 +75,50 @@ class SelectedElementRenderer implements IRenderer<SelectableElement, ISelectedE
renderTemplate
(
container
:
HTMLElement
):
ISelectedElementTemplateData
{
const
data
:
ISelectedElementTemplateData
=
Object
.
create
(
null
);
data
.
element
=
dom
.
append
(
container
,
$
(
'
.selected_element
'
));
data
.
checkbox
=
<
HTMLInputElement
>
$
(
'
input
'
);
const
entry
=
dom
.
append
(
container
,
$
(
'
.quick-input-checkbox-list-entry
'
));
const
label
=
dom
.
append
(
entry
,
$
(
'
label.quick-input-checkbox-list-label
'
));
// Entry
data
.
checkbox
=
<
HTMLInputElement
>
dom
.
append
(
label
,
$
(
'
input.quick-input-checkbox-list-checkbox
'
));
data
.
checkbox
.
type
=
'
checkbox
'
;
data
.
toDisposeElement
=
[];
data
.
toDisposeTemplate
=
[];
data
.
toDisposeTemplate
.
push
(
dom
.
addStandardDisposableListener
(
data
.
checkbox
,
dom
.
EventType
.
CHANGE
,
e
=>
{
data
.
contex
t
.
selected
=
data
.
checkbox
.
checked
;
data
.
elemen
t
.
selected
=
data
.
checkbox
.
checked
;
}));
dom
.
append
(
data
.
element
,
data
.
checkbox
);
const
rows
=
dom
.
append
(
label
,
$
(
'
.quick-input-checkbox-list-rows
'
));
const
row1
=
dom
.
append
(
rows
,
$
(
'
.quick-input-checkbox-list-row
'
));
const
row2
=
dom
.
append
(
rows
,
$
(
'
.quick-input-checkbox-list-row
'
));
// Label
data
.
label
=
new
IconLabel
(
row1
,
{
supportHighlights
:
true
,
supportDescriptionHighlights
:
true
});
data
.
name
=
dom
.
append
(
data
.
element
,
$
(
'
span.label
'
));
// Detail
const
detailContainer
=
dom
.
append
(
row2
,
$
(
'
.quick-input-checkbox-list-label-meta
'
));
data
.
detail
=
new
HighlightedLabel
(
detailContainer
);
return
data
;
}
renderElement
(
element
:
SelectableElement
,
index
:
number
,
data
:
ISelectedElementTemplateData
):
void
{
dispose
(
data
.
toDisposeElement
);
data
.
context
=
element
;
data
.
name
.
textContent
=
element
.
label
;
data
.
element
.
title
=
data
.
name
.
textContent
;
data
.
element
=
element
;
data
.
checkbox
.
checked
=
element
.
selected
;
data
.
toDisposeElement
.
push
(
element
.
onSelected
(
selected
=>
data
.
checkbox
.
checked
=
selected
));
const
{
labelHighlights
,
descriptionHighlights
,
detailHighlights
}
=
element
;
// Label
const
options
:
IIconLabelValueOptions
=
Object
.
create
(
null
);
options
.
matches
=
labelHighlights
||
[];
options
.
descriptionTitle
=
element
.
item
.
description
;
options
.
descriptionMatches
=
descriptionHighlights
||
[];
data
.
label
.
setValue
(
element
.
item
.
label
,
element
.
item
.
description
,
options
);
// Meta
data
.
detail
.
set
(
element
.
item
.
detail
,
detailHighlights
);
}
disposeTemplate
(
data
:
ISelectedElementTemplateData
):
void
{
...
...
@@ -109,7 +129,7 @@ class SelectedElementRenderer implements IRenderer<SelectableElement, ISelectedE
class
SelectedElementDelegate
implements
IDelegate
<
SelectableElement
>
{
getHeight
(
element
:
SelectableElement
):
number
{
return
22
;
return
element
.
item
.
detail
?
44
:
22
;
}
getTemplateId
(
element
:
SelectableElement
):
string
{
...
...
@@ -147,10 +167,10 @@ export class QuickInputCheckboxList {
this
.
elements
=
elements
.
map
((
item
,
index
)
=>
new
SelectableElement
({
index
,
item
,
label
:
item
.
label
,
selected
:
!!
item
.
selected
}));
this
.
list
.
splice
(
0
,
this
.
list
.
length
,
this
.
elements
);
this
.
list
.
focusFirst
();
}
getSelectedElements
()
{
...
...
@@ -182,9 +202,9 @@ export class QuickInputCheckboxList {
// Filter by value (since we support octicons, use octicon aware fuzzy matching)
else
{
this
.
elements
.
forEach
(
element
=>
{
const
labelHighlights
=
matchesFuzzyOcticonAware
(
query
,
parseOcticons
(
element
.
label
));
const
descriptionHighlights
=
undefined
;
// TODO matchesFuzzyOcticonAware(query, parseOcticons(element.description
));
const
detailHighlights
=
undefined
;
// TODO matchesFuzzyOcticonAware(query, parseOcticons(element.detail
));
const
labelHighlights
=
matchesFuzzyOcticonAware
(
query
,
parseOcticons
(
element
.
item
.
label
));
const
descriptionHighlights
=
matchesFuzzyOcticonAware
(
query
,
parseOcticons
(
element
.
item
.
description
||
''
));
const
detailHighlights
=
matchesFuzzyOcticonAware
(
query
,
parseOcticons
(
element
.
item
.
detail
||
''
));
if
(
element
.
shouldAlwaysShow
||
labelHighlights
||
descriptionHighlights
||
detailHighlights
)
{
element
.
labelHighlights
=
labelHighlights
;
...
...
@@ -211,10 +231,8 @@ export class QuickInputCheckboxList {
this
.
list
.
splice
(
0
,
this
.
list
.
length
,
this
.
elements
.
filter
(
element
=>
!
element
.
hidden
));
this
.
list
.
layout
();
if
(
query
)
{
this
.
list
.
focusFirst
();
}
}
toggleCheckbox
()
{
const
elements
=
this
.
list
.
getFocusedElements
();
...
...
@@ -240,5 +258,5 @@ function compareEntries(elementA: SelectableElement, elementB: SelectableElement
return
1
;
}
return
compareAnything
(
elementA
.
label
,
elementB
.
label
,
lookFor
);
return
compareAnything
(
elementA
.
item
.
label
,
elementB
.
item
.
label
,
lookFor
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录