Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
18570a1c
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,发现更多精彩内容 >>
提交
18570a1c
编写于
11月 28, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
list: proper identity provider
上级
9a57732a
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
41 addition
and
31 deletion
+41
-31
src/vs/base/browser/ui/list/list.ts
src/vs/base/browser/ui/list/list.ts
+4
-0
src/vs/base/browser/ui/list/listWidget.ts
src/vs/base/browser/ui/list/listWidget.ts
+6
-11
src/vs/base/browser/ui/tree/abstractTree.ts
src/vs/base/browser/ui/tree/abstractTree.ts
+7
-3
src/vs/workbench/browser/parts/quickinput/quickInputList.ts
src/vs/workbench/browser/parts/quickinput/quickInputList.ts
+1
-1
src/vs/workbench/parts/debug/browser/breakpointsView.ts
src/vs/workbench/parts/debug/browser/breakpointsView.ts
+1
-1
src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts
...nch/parts/files/electron-browser/views/openEditorsView.ts
+1
-1
src/vs/workbench/parts/markers/electron-browser/markersPanel.ts
.../workbench/parts/markers/electron-browser/markersPanel.ts
+7
-1
src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts
.../workbench/parts/preferences/browser/keybindingsEditor.ts
+1
-1
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
+13
-12
未找到文件。
src/vs/base/browser/ui/list/list.ts
浏览文件 @
18570a1c
...
@@ -49,3 +49,7 @@ export interface IListContextMenuEvent<T> {
...
@@ -49,3 +49,7 @@ export interface IListContextMenuEvent<T> {
index
:
number
|
undefined
;
index
:
number
|
undefined
;
anchor
:
HTMLElement
|
{
x
:
number
;
y
:
number
;
}
|
undefined
;
anchor
:
HTMLElement
|
{
x
:
number
;
y
:
number
;
}
|
undefined
;
}
}
export
interface
IIdentityProvider
<
T
>
{
getId
(
element
:
T
):
{
toString
():
string
;
};
}
\ No newline at end of file
src/vs/base/browser/ui/list/listWidget.ts
浏览文件 @
18570a1c
...
@@ -16,7 +16,7 @@ import { KeyCode } from 'vs/base/common/keyCodes';
...
@@ -16,7 +16,7 @@ import { KeyCode } from 'vs/base/common/keyCodes';
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
Event
,
Emitter
,
EventBufferer
,
chain
,
mapEvent
,
anyEvent
}
from
'
vs/base/common/event
'
;
import
{
Event
,
Emitter
,
EventBufferer
,
chain
,
mapEvent
,
anyEvent
}
from
'
vs/base/common/event
'
;
import
{
domEvent
}
from
'
vs/base/browser/event
'
;
import
{
domEvent
}
from
'
vs/base/browser/event
'
;
import
{
IListVirtualDelegate
,
IListRenderer
,
IListEvent
,
IListContextMenuEvent
,
IListMouseEvent
,
IListTouchEvent
,
IListGestureEvent
}
from
'
./list
'
;
import
{
IListVirtualDelegate
,
IListRenderer
,
IListEvent
,
IListContextMenuEvent
,
IListMouseEvent
,
IListTouchEvent
,
IListGestureEvent
,
IIdentityProvider
}
from
'
./list
'
;
import
{
ListView
,
IListViewOptions
}
from
'
./listView
'
;
import
{
ListView
,
IListViewOptions
}
from
'
./listView
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
mixin
}
from
'
vs/base/common/objects
'
;
import
{
mixin
}
from
'
vs/base/common/objects
'
;
...
@@ -25,10 +25,6 @@ import { ISpliceable } from 'vs/base/common/sequence';
...
@@ -25,10 +25,6 @@ import { ISpliceable } from 'vs/base/common/sequence';
import
{
CombinedSpliceable
}
from
'
vs/base/browser/ui/list/splice
'
;
import
{
CombinedSpliceable
}
from
'
vs/base/browser/ui/list/splice
'
;
import
{
clamp
}
from
'
vs/base/common/numbers
'
;
import
{
clamp
}
from
'
vs/base/common/numbers
'
;
export
interface
IIdentityProvider
<
T
,
R
extends
string
|
number
=
string
|
number
>
{
(
element
:
T
):
R
;
}
interface
ITraitChangeEvent
{
interface
ITraitChangeEvent
{
indexes
:
number
[];
indexes
:
number
[];
browserEvent
?:
UIEvent
;
browserEvent
?:
UIEvent
;
...
@@ -187,7 +183,7 @@ class Trait<T> implements ISpliceable<boolean>, IDisposable {
...
@@ -187,7 +183,7 @@ class Trait<T> implements ISpliceable<boolean>, IDisposable {
class
FocusTrait
<
T
>
extends
Trait
<
T
>
{
class
FocusTrait
<
T
>
extends
Trait
<
T
>
{
constructor
(
constructor
(
private
getDomId
:
IIdentityProvider
<
number
,
string
>
private
getDomId
:
(
index
:
number
)
=>
string
)
{
)
{
super
(
'
focused
'
);
super
(
'
focused
'
);
}
}
...
@@ -215,17 +211,16 @@ class TraitSpliceable<T> implements ISpliceable<T> {
...
@@ -215,17 +211,16 @@ class TraitSpliceable<T> implements ISpliceable<T> {
constructor
(
constructor
(
private
trait
:
Trait
<
T
>
,
private
trait
:
Trait
<
T
>
,
private
view
:
ListView
<
T
>
,
private
view
:
ListView
<
T
>
,
private
getId
?:
IIdentityProvider
<
T
>
private
identityProvider
?:
IIdentityProvider
<
T
>
)
{
}
)
{
}
splice
(
start
:
number
,
deleteCount
:
number
,
elements
:
T
[]):
void
{
splice
(
start
:
number
,
deleteCount
:
number
,
elements
:
T
[]):
void
{
if
(
!
this
.
getId
)
{
if
(
!
this
.
identityProvider
)
{
return
this
.
trait
.
splice
(
start
,
deleteCount
,
elements
.
map
(
e
=>
false
));
return
this
.
trait
.
splice
(
start
,
deleteCount
,
elements
.
map
(
e
=>
false
));
}
}
const
getId
=
this
.
getId
;
const
pastElementsWithTrait
=
this
.
trait
.
get
().
map
(
i
=>
this
.
identityProvider
!
.
getId
(
this
.
view
.
element
(
i
)).
toString
());
const
pastElementsWithTrait
=
this
.
trait
.
get
().
map
(
i
=>
getId
(
this
.
view
.
element
(
i
)));
const
elementsWithTrait
=
elements
.
map
(
e
=>
pastElementsWithTrait
.
indexOf
(
this
.
identityProvider
!
.
getId
(
e
).
toString
())
>
-
1
);
const
elementsWithTrait
=
elements
.
map
(
e
=>
pastElementsWithTrait
.
indexOf
(
getId
(
e
))
>
-
1
);
this
.
trait
.
splice
(
start
,
deleteCount
,
elementsWithTrait
);
this
.
trait
.
splice
(
start
,
deleteCount
,
elementsWithTrait
);
}
}
...
...
src/vs/base/browser/ui/tree/abstractTree.ts
浏览文件 @
18570a1c
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
import
'
vs/css!./media/tree
'
;
import
'
vs/css!./media/tree
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IListOptions
,
List
,
I
IdentityProvider
,
I
MultipleSelectionController
,
IListStyles
,
IAccessibilityProvider
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
{
IListOptions
,
List
,
IMultipleSelectionController
,
IListStyles
,
IAccessibilityProvider
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
{
IListVirtualDelegate
,
IListRenderer
,
IListMouseEvent
,
IListEvent
,
IListContextMenuEvent
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
IListVirtualDelegate
,
IListRenderer
,
IListMouseEvent
,
IListEvent
,
IListContextMenuEvent
,
IIdentityProvider
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
append
,
$
,
toggleClass
}
from
'
vs/base/browser/dom
'
;
import
{
append
,
$
,
toggleClass
}
from
'
vs/base/browser/dom
'
;
import
{
Event
,
Relay
,
chain
,
mapEvent
}
from
'
vs/base/common/event
'
;
import
{
Event
,
Relay
,
chain
,
mapEvent
}
from
'
vs/base/common/event
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
...
@@ -23,7 +23,11 @@ export function createComposedTreeListOptions<T, R extends { element: T }>(optio
...
@@ -23,7 +23,11 @@ export function createComposedTreeListOptions<T, R extends { element: T }>(optio
if
(
options
.
identityProvider
)
{
if
(
options
.
identityProvider
)
{
const
ip
=
options
.
identityProvider
;
const
ip
=
options
.
identityProvider
;
identityProvider
=
el
=>
ip
(
el
.
element
);
identityProvider
=
{
getId
(
el
)
{
return
ip
.
getId
(
el
.
element
);
}
};
}
}
let
multipleSelectionController
:
IMultipleSelectionController
<
R
>
|
undefined
=
undefined
;
let
multipleSelectionController
:
IMultipleSelectionController
<
R
>
|
undefined
=
undefined
;
...
...
src/vs/workbench/browser/parts/quickinput/quickInputList.ts
浏览文件 @
18570a1c
...
@@ -244,7 +244,7 @@ export class QuickInputList {
...
@@ -244,7 +244,7 @@ export class QuickInputList {
this
.
container
=
dom
.
append
(
this
.
parent
,
$
(
'
.quick-input-list
'
));
this
.
container
=
dom
.
append
(
this
.
parent
,
$
(
'
.quick-input-list
'
));
const
delegate
=
new
ListElementDelegate
();
const
delegate
=
new
ListElementDelegate
();
this
.
list
=
this
.
instantiationService
.
createInstance
(
WorkbenchList
,
this
.
container
,
delegate
,
[
new
ListElementRenderer
()],
{
this
.
list
=
this
.
instantiationService
.
createInstance
(
WorkbenchList
,
this
.
container
,
delegate
,
[
new
ListElementRenderer
()],
{
identityProvider
:
element
=>
element
.
label
,
identityProvider
:
{
getId
:
element
=>
element
.
label
}
,
openController
:
{
shouldOpen
:
()
=>
false
},
// Workaround #58124
openController
:
{
shouldOpen
:
()
=>
false
},
// Workaround #58124
setRowLineHeight
:
false
,
setRowLineHeight
:
false
,
multipleSelectionSupport
:
false
multipleSelectionSupport
:
false
...
...
src/vs/workbench/parts/debug/browser/breakpointsView.ts
浏览文件 @
18570a1c
...
@@ -74,7 +74,7 @@ export class BreakpointsView extends ViewletPanel {
...
@@ -74,7 +74,7 @@ export class BreakpointsView extends ViewletPanel {
this
.
instantiationService
.
createInstance
(
FunctionBreakpointsRenderer
),
this
.
instantiationService
.
createInstance
(
FunctionBreakpointsRenderer
),
new
FunctionBreakpointInputRenderer
(
this
.
debugService
,
this
.
contextViewService
,
this
.
themeService
)
new
FunctionBreakpointInputRenderer
(
this
.
debugService
,
this
.
contextViewService
,
this
.
themeService
)
],
{
],
{
identityProvider
:
element
=>
element
.
getId
()
,
identityProvider
:
{
getId
:
element
=>
element
.
getId
()
}
,
multipleSelectionSupport
:
false
multipleSelectionSupport
:
false
})
as
WorkbenchList
<
IEnablement
>
;
})
as
WorkbenchList
<
IEnablement
>
;
...
...
src/vs/workbench/parts/files/electron-browser/views/openEditorsView.ts
浏览文件 @
18570a1c
...
@@ -217,7 +217,7 @@ export class OpenEditorsView extends ViewletPanel {
...
@@ -217,7 +217,7 @@ export class OpenEditorsView extends ViewletPanel {
new
EditorGroupRenderer
(
this
.
keybindingService
,
this
.
instantiationService
,
this
.
editorGroupService
),
new
EditorGroupRenderer
(
this
.
keybindingService
,
this
.
instantiationService
,
this
.
editorGroupService
),
new
OpenEditorRenderer
(
getSelectedElements
,
this
.
instantiationService
,
this
.
keybindingService
,
this
.
configurationService
,
this
.
editorGroupService
)
new
OpenEditorRenderer
(
getSelectedElements
,
this
.
instantiationService
,
this
.
keybindingService
,
this
.
configurationService
,
this
.
editorGroupService
)
],
{
],
{
identityProvider
:
(
element
:
OpenEditor
|
IEditorGroup
)
=>
element
instanceof
OpenEditor
?
element
.
getId
()
:
element
.
id
.
toString
()
,
identityProvider
:
{
getId
:
(
element
:
OpenEditor
|
IEditorGroup
)
=>
element
instanceof
OpenEditor
?
element
.
getId
()
:
element
.
id
.
toString
()
}
,
selectOnMouseDown
:
false
/* disabled to better support DND */
selectOnMouseDown
:
false
/* disabled to better support DND */
})
as
WorkbenchList
<
OpenEditor
|
IEditorGroup
>
;
})
as
WorkbenchList
<
OpenEditor
|
IEditorGroup
>
;
this
.
disposables
.
push
(
this
.
list
);
this
.
disposables
.
push
(
this
.
list
);
...
...
src/vs/workbench/parts/markers/electron-browser/markersPanel.ts
浏览文件 @
18570a1c
...
@@ -289,6 +289,12 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
...
@@ -289,6 +289,12 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
this
.
filter
=
new
Filter
();
this
.
filter
=
new
Filter
();
const
accessibilityProvider
=
this
.
instantiationService
.
createInstance
(
MarkersTreeAccessibilityProvider
);
const
accessibilityProvider
=
this
.
instantiationService
.
createInstance
(
MarkersTreeAccessibilityProvider
);
const
identityProvider
=
{
getId
(
element
:
TreeElement
)
{
return
element
.
hash
;
}
};
this
.
tree
=
this
.
instantiationService
.
createInstance
(
WorkbenchObjectTree
,
this
.
tree
=
this
.
instantiationService
.
createInstance
(
WorkbenchObjectTree
,
this
.
treeContainer
,
this
.
treeContainer
,
virtualDelegate
,
virtualDelegate
,
...
@@ -296,7 +302,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
...
@@ -296,7 +302,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
{
{
filter
:
this
.
filter
,
filter
:
this
.
filter
,
accessibilityProvider
,
accessibilityProvider
,
identityProvider
:
(
element
:
TreeElement
)
=>
element
.
hash
identityProvider
}
}
)
as
any
as
WorkbenchObjectTree
<
TreeElement
,
FilterData
>
;
)
as
any
as
WorkbenchObjectTree
<
TreeElement
,
FilterData
>
;
...
...
src/vs/workbench/parts/preferences/browser/keybindingsEditor.ts
浏览文件 @
18570a1c
...
@@ -398,7 +398,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
...
@@ -398,7 +398,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
this
.
keybindingsListContainer
=
DOM
.
append
(
parent
,
$
(
'
.keybindings-list-container
'
));
this
.
keybindingsListContainer
=
DOM
.
append
(
parent
,
$
(
'
.keybindings-list-container
'
));
this
.
keybindingsList
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
WorkbenchList
,
this
.
keybindingsListContainer
,
new
Delegate
(),
[
new
KeybindingHeaderRenderer
(),
new
KeybindingItemRenderer
(
this
,
this
.
keybindingsService
)],
this
.
keybindingsList
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
WorkbenchList
,
this
.
keybindingsListContainer
,
new
Delegate
(),
[
new
KeybindingHeaderRenderer
(),
new
KeybindingItemRenderer
(
this
,
this
.
keybindingsService
)],
{
identityProvider
:
e
=>
e
.
id
,
mouseSupport
:
true
,
ariaLabel
:
localize
(
'
keybindingsLabel
'
,
"
Keybindings
"
),
setRowLineHeight
:
false
}))
as
WorkbenchList
<
IListEntry
>
;
{
identityProvider
:
{
getId
:
e
=>
e
.
id
}
,
mouseSupport
:
true
,
ariaLabel
:
localize
(
'
keybindingsLabel
'
,
"
Keybindings
"
),
setRowLineHeight
:
false
}))
as
WorkbenchList
<
IListEntry
>
;
this
.
_register
(
this
.
keybindingsList
.
onContextMenu
(
e
=>
this
.
onContextMenu
(
e
)));
this
.
_register
(
this
.
keybindingsList
.
onContextMenu
(
e
=>
this
.
onContextMenu
(
e
)));
this
.
_register
(
this
.
keybindingsList
.
onFocusChange
(
e
=>
this
.
onFocusChange
(
e
)));
this
.
_register
(
this
.
keybindingsList
.
onFocusChange
(
e
=>
this
.
onFocusChange
(
e
)));
this
.
_register
(
this
.
keybindingsList
.
onDidFocus
(()
=>
{
this
.
_register
(
this
.
keybindingsList
.
onDidFocus
(()
=>
{
...
...
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
浏览文件 @
18570a1c
...
@@ -262,10 +262,9 @@ class MainPanel extends ViewletPanel {
...
@@ -262,10 +262,9 @@ class MainPanel extends ViewletPanel {
protected
renderBody
(
container
:
HTMLElement
):
void
{
protected
renderBody
(
container
:
HTMLElement
):
void
{
const
delegate
=
new
ProvidersListDelegate
();
const
delegate
=
new
ProvidersListDelegate
();
const
renderer
=
this
.
instantiationService
.
createInstance
(
ProviderRenderer
);
const
renderer
=
this
.
instantiationService
.
createInstance
(
ProviderRenderer
);
const
identityProvider
=
{
getId
:
r
=>
r
.
provider
.
id
};
this
.
list
=
this
.
instantiationService
.
createInstance
(
WorkbenchList
,
container
,
delegate
,
[
renderer
],
{
this
.
list
=
this
.
instantiationService
.
createInstance
(
WorkbenchList
,
container
,
delegate
,
[
renderer
],
{
identityProvider
})
as
WorkbenchList
<
ISCMRepository
>
;
identityProvider
:
repository
=>
repository
.
provider
.
id
})
as
WorkbenchList
<
ISCMRepository
>
;
this
.
list
.
onSelectionChange
(
this
.
onListSelectionChange
,
this
,
this
.
disposables
);
this
.
list
.
onSelectionChange
(
this
.
onListSelectionChange
,
this
,
this
.
disposables
);
this
.
list
.
onContextMenu
(
this
.
onListContextMenu
,
this
,
this
.
disposables
);
this
.
list
.
onContextMenu
(
this
.
onListContextMenu
,
this
,
this
.
disposables
);
...
@@ -580,16 +579,18 @@ class ProviderListDelegate implements IListVirtualDelegate<ISCMResourceGroup | I
...
@@ -580,16 +579,18 @@ class ProviderListDelegate implements IListVirtualDelegate<ISCMResourceGroup | I
}
}
}
}
function
scmResourceIdentityProvider
(
r
:
ISCMResourceGroup
|
ISCMResource
):
string
{
const
scmResourceIdentityProvider
=
{
if
(
isSCMResource
(
r
))
{
getId
(
r
:
ISCMResourceGroup
|
ISCMResource
):
string
{
const
group
=
r
.
resourceGroup
;
if
(
isSCMResource
(
r
))
{
const
provider
=
group
.
provider
;
const
group
=
r
.
resourceGroup
;
return
`
${
provider
.
contextValue
}
/
${
group
.
id
}
/
${
r
.
sourceUri
.
toString
()}
`
;
const
provider
=
group
.
provider
;
}
else
{
return
`
${
provider
.
contextValue
}
/
${
group
.
id
}
/
${
r
.
sourceUri
.
toString
()}
`
;
const
provider
=
r
.
provider
;
}
else
{
return
`
${
provider
.
contextValue
}
/
${
r
.
id
}
`
;
const
provider
=
r
.
provider
;
return
`
${
provider
.
contextValue
}
/
${
r
.
id
}
`
;
}
}
}
}
}
;
function
isGroupVisible
(
group
:
ISCMResourceGroup
)
{
function
isGroupVisible
(
group
:
ISCMResourceGroup
)
{
return
group
.
elements
.
length
>
0
||
!
group
.
hideWhenEmpty
;
return
group
.
elements
.
length
>
0
||
!
group
.
hideWhenEmpty
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录