Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
920493df
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,体验更适合开发者的 AI 搜索 >>
提交
920493df
编写于
3月 22, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - adopt splitview in references widget, nuke VSash
上级
a19adff3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
61 addition
and
130 deletion
+61
-130
src/vs/editor/contrib/referenceSearch/referencesWidget.ts
src/vs/editor/contrib/referenceSearch/referencesWidget.ts
+61
-130
未找到文件。
src/vs/editor/contrib/referenceSearch/referencesWidget.ts
浏览文件 @
920493df
...
...
@@ -5,7 +5,7 @@
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
IMouseEvent
}
from
'
vs/base/browser/mouseEvent
'
;
import
{
ISashEvent
,
IVerticalSashLayoutProvider
,
Sash
}
from
'
vs/base/browser/ui/sash/sash
'
;
import
{
Orientation
}
from
'
vs/base/browser/ui/sash/sash
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
dispose
,
IDisposable
,
IReference
}
from
'
vs/base/common/lifecycle
'
;
...
...
@@ -35,6 +35,8 @@ import { ITreeRenderer, IAsyncDataSource } from 'vs/base/browser/ui/tree/tree';
import
{
IAsyncDataTreeOptions
}
from
'
vs/base/browser/ui/tree/asyncDataTree
'
;
import
{
IListVirtualDelegate
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
FuzzyScore
}
from
'
vs/base/common/filters
'
;
import
{
SplitView
,
Sizing
}
from
'
vs/base/browser/ui/splitview/splitview
'
;
class
DecorationsManager
implements
IDisposable
{
...
...
@@ -155,72 +157,6 @@ class DecorationsManager implements IDisposable {
}
}
class
VSash
{
private
_disposables
:
IDisposable
[]
=
[];
private
_sash
:
Sash
;
private
_ratio
:
number
;
private
_height
:
number
;
private
_width
:
number
;
private
_onDidChangePercentages
=
new
Emitter
<
VSash
>
();
constructor
(
container
:
HTMLElement
,
ratio
:
number
)
{
this
.
_ratio
=
ratio
;
this
.
_sash
=
new
Sash
(
container
,
<
IVerticalSashLayoutProvider
>
{
getVerticalSashLeft
:
()
=>
this
.
_width
*
this
.
_ratio
,
getVerticalSashHeight
:
()
=>
this
.
_height
});
// compute the current widget clientX postion since
// the sash works with clientX when dragging
let
clientX
:
number
;
this
.
_disposables
.
push
(
this
.
_sash
.
onDidStart
((
e
:
ISashEvent
)
=>
{
clientX
=
e
.
startX
-
(
this
.
_width
*
this
.
ratio
);
}));
this
.
_disposables
.
push
(
this
.
_sash
.
onDidChange
((
e
:
ISashEvent
)
=>
{
// compute the new position of the sash and from that
// compute the new ratio that we are using
let
newLeft
=
e
.
currentX
-
clientX
;
if
(
newLeft
>
20
&&
newLeft
+
20
<
this
.
_width
)
{
this
.
_ratio
=
newLeft
/
this
.
_width
;
this
.
_sash
.
layout
();
this
.
_onDidChangePercentages
.
fire
(
this
);
}
}));
}
dispose
()
{
this
.
_sash
.
dispose
();
this
.
_onDidChangePercentages
.
dispose
();
dispose
(
this
.
_disposables
);
}
get
onDidChangePercentages
()
{
return
this
.
_onDidChangePercentages
.
event
;
}
set
width
(
value
:
number
)
{
this
.
_width
=
value
;
this
.
_sash
.
layout
();
}
set
height
(
value
:
number
)
{
this
.
_height
=
value
;
this
.
_sash
.
layout
();
}
get
percentages
()
{
let
left
=
100
*
this
.
_ratio
;
let
right
=
100
-
left
;
return
[
`
${
left
}
%`
,
`
${
right
}
%`
];
}
get
ratio
()
{
return
this
.
_ratio
;
}
}
export
interface
LayoutData
{
ratio
:
number
;
heightInLines
:
number
;
...
...
@@ -248,14 +184,14 @@ export class ReferenceWidget extends PeekViewWidget {
private
_tree
:
WorkbenchAsyncDataTree
<
ReferencesModel
|
FileReferences
,
TreeElement
,
FuzzyScore
>
;
private
_treeContainer
:
HTMLElement
;
private
_sash
:
VSash
;
// private _sash: VSash;
private
_splitView
:
SplitView
;
private
_preview
:
ICodeEditor
;
private
_previewModelReference
:
IReference
<
ITextEditorModel
>
;
private
_previewNotAvailableMessage
:
TextModel
;
private
_previewContainer
:
HTMLElement
;
private
_messageContainer
:
HTMLElement
;
private
height
:
number
|
undefined
;
private
width
:
number
|
undefined
;
private
_dim
:
dom
.
Dimension
=
{
height
:
0
,
width
:
0
};
constructor
(
editor
:
ICodeEditor
,
...
...
@@ -275,6 +211,14 @@ export class ReferenceWidget extends PeekViewWidget {
this
.
create
();
}
dispose
():
void
{
this
.
setModel
(
undefined
);
this
.
_callOnDispose
=
dispose
(
this
.
_callOnDispose
);
dispose
<
IDisposable
>
(
this
.
_preview
,
this
.
_previewNotAvailableMessage
,
this
.
_tree
,
this
.
_previewModelReference
);
this
.
_splitView
.
dispose
();
super
.
dispose
();
}
private
_applyTheme
(
theme
:
ITheme
)
{
const
borderColor
=
theme
.
getColor
(
peekViewBorder
)
||
Color
.
transparent
;
this
.
style
({
...
...
@@ -286,13 +230,6 @@ export class ReferenceWidget extends PeekViewWidget {
});
}
public
dispose
():
void
{
this
.
setModel
(
undefined
);
this
.
_callOnDispose
=
dispose
(
this
.
_callOnDispose
);
dispose
<
IDisposable
>
(
this
.
_preview
,
this
.
_previewNotAvailableMessage
,
this
.
_tree
,
this
.
_sash
,
this
.
_previewModelReference
);
super
.
dispose
();
}
get
onDidSelectReference
():
Event
<
SelectionEvent
>
{
return
this
.
_onDidSelectReference
.
event
;
}
...
...
@@ -323,6 +260,8 @@ export class ReferenceWidget extends PeekViewWidget {
this
.
_messageContainer
=
dom
.
append
(
containerElement
,
dom
.
$
(
'
div.messages
'
));
dom
.
hide
(
this
.
_messageContainer
);
this
.
_splitView
=
new
SplitView
(
containerElement
,
{
orientation
:
Orientation
.
HORIZONTAL
});
// editor
this
.
_previewContainer
=
dom
.
append
(
containerElement
,
dom
.
$
(
'
div.preview.inline
'
));
let
options
:
IEditorOptions
=
{
...
...
@@ -344,25 +283,8 @@ export class ReferenceWidget extends PeekViewWidget {
dom
.
hide
(
this
.
_previewContainer
);
this
.
_previewNotAvailableMessage
=
TextModel
.
createFromString
(
nls
.
localize
(
'
missingPreviewMessage
'
,
"
no preview available
"
));
// sash
this
.
_sash
=
new
VSash
(
containerElement
,
this
.
layoutData
.
ratio
||
0.8
);
this
.
_sash
.
onDidChangePercentages
(()
=>
{
let
[
left
,
right
]
=
this
.
_sash
.
percentages
;
this
.
_previewContainer
.
style
.
width
=
left
;
this
.
_treeContainer
.
style
.
width
=
right
;
this
.
_preview
.
layout
();
this
.
_tree
.
layout
(
this
.
height
,
this
.
width
&&
this
.
width
*
(
1
-
this
.
_sash
.
ratio
));
this
.
layoutData
.
ratio
=
this
.
_sash
.
ratio
;
});
// tree
this
.
_treeContainer
=
dom
.
append
(
containerElement
,
dom
.
$
(
'
div.ref-tree.inline
'
));
const
renderers
=
[
this
.
_instantiationService
.
createInstance
(
FileReferencesRenderer
),
this
.
_instantiationService
.
createInstance
(
OneReferenceRenderer
),
];
const
treeOptions
:
IAsyncDataTreeOptions
<
TreeElement
,
FuzzyScore
>
=
{
ariaLabel
:
nls
.
localize
(
'
treeAriaLabel
'
,
"
References
"
),
keyboardSupport
:
this
.
_defaultTreeKeyboardSupport
,
...
...
@@ -370,20 +292,48 @@ export class ReferenceWidget extends PeekViewWidget {
keyboardNavigationLabelProvider
:
this
.
_instantiationService
.
createInstance
(
StringRepresentationProvider
),
identityProvider
:
new
IdentityProvider
()
};
const
treeDataSource
=
this
.
_instantiationService
.
createInstance
(
DataSource
);
this
.
_tree
=
this
.
_instantiationService
.
createInstance
<
HTMLElement
,
IListVirtualDelegate
<
TreeElement
>
,
ITreeRenderer
<
any
,
FuzzyScore
,
any
>
[],
IAsyncDataSource
<
ReferencesModel
|
FileReferences
,
TreeElement
>
,
IAsyncDataTreeOptions
<
TreeElement
,
FuzzyScore
>
,
WorkbenchAsyncDataTree
<
ReferencesModel
|
FileReferences
,
TreeElement
,
FuzzyScore
>>
(
WorkbenchAsyncDataTree
,
this
.
_treeContainer
,
new
Delegate
(),
renderers
,
treeDataSource
,
[
this
.
_instantiationService
.
createInstance
(
FileReferencesRenderer
),
this
.
_instantiationService
.
createInstance
(
OneReferenceRenderer
),
],
this
.
_instantiationService
.
createInstance
(
DataSource
),
treeOptions
);
ctxReferenceWidgetSearchTreeFocused
.
bindTo
(
this
.
_tree
.
contextKeyService
);
// split stuff
this
.
_splitView
.
addView
({
onDidChange
:
Event
.
None
,
element
:
this
.
_previewContainer
,
minimumSize
:
200
,
maximumSize
:
Number
.
MAX_VALUE
,
layout
:
(
width
)
=>
{
this
.
_preview
.
layout
({
height
:
this
.
_dim
.
height
,
width
});
}
},
Sizing
.
Distribute
);
this
.
_splitView
.
addView
({
onDidChange
:
Event
.
None
,
element
:
this
.
_treeContainer
,
minimumSize
:
100
,
maximumSize
:
Number
.
MAX_VALUE
,
layout
:
(
width
)
=>
{
this
.
_treeContainer
.
style
.
height
=
`
${
this
.
_dim
.
height
}
px`
;
this
.
_treeContainer
.
style
.
width
=
`
${
width
}
px`
;
this
.
_tree
.
layout
(
this
.
_dim
.
height
,
width
);
}
},
Sizing
.
Distribute
);
this
.
_splitView
.
onDidSashChange
(()
=>
{
if
(
this
.
_dim
.
width
)
{
this
.
layoutData
.
ratio
=
this
.
_splitView
.
getViewSize
(
0
)
/
this
.
_dim
.
width
;
}
},
undefined
,
this
.
_disposables
);
// listen on selection and focus
let
onEvent
=
(
element
:
any
,
kind
:
'
show
'
|
'
goto
'
|
'
side
'
)
=>
{
if
(
element
instanceof
OneReference
)
{
...
...
@@ -430,36 +380,18 @@ export class ReferenceWidget extends PeekViewWidget {
dom
.
hide
(
this
.
_treeContainer
);
}
protected
_doLayoutBody
(
heightInPixel
:
number
,
widthInPixel
:
number
):
void
{
super
.
_doLayoutBody
(
heightInPixel
,
widthInPixel
);
this
.
height
=
heightInPixel
;
this
.
width
=
widthInPixel
;
const
height
=
heightInPixel
+
'
px
'
;
this
.
_sash
.
height
=
heightInPixel
;
this
.
_sash
.
width
=
widthInPixel
;
// set height/width
const
[
left
,
right
]
=
this
.
_sash
.
percentages
;
this
.
_previewContainer
.
style
.
height
=
height
;
this
.
_previewContainer
.
style
.
width
=
left
;
this
.
_treeContainer
.
style
.
height
=
height
;
this
.
_treeContainer
.
style
.
width
=
right
;
// forward
this
.
_tree
.
layout
(
heightInPixel
,
widthInPixel
*
(
1
-
this
.
_sash
.
ratio
));
this
.
_preview
.
layout
();
// store layout data
this
.
layoutData
=
{
heightInLines
:
this
.
_viewZone
?
this
.
_viewZone
.
heightInLines
:
0
,
ratio
:
this
.
_sash
.
ratio
};
protected
_onWidth
(
width
:
number
)
{
if
(
this
.
_dim
)
{
this
.
_doLayoutBody
(
this
.
_dim
.
height
,
width
);
}
}
public
_onWidth
(
widthInPixel
:
number
):
void
{
this
.
_sash
.
width
=
widthInPixel
;
this
.
_preview
.
layout
();
protected
_doLayoutBody
(
heightInPixel
:
number
,
widthInPixel
:
number
):
void
{
super
.
_doLayoutBody
(
heightInPixel
,
widthInPixel
);
this
.
_dim
=
{
height
:
heightInPixel
,
width
:
widthInPixel
};
this
.
layoutData
.
heightInLines
=
this
.
_viewZone
?
this
.
_viewZone
.
heightInLines
:
this
.
layoutData
.
heightInLines
;
this
.
_splitView
.
layout
(
widthInPixel
);
this
.
_splitView
.
resizeView
(
0
,
widthInPixel
*
this
.
layoutData
.
ratio
);
}
public
setSelection
(
selection
:
OneReference
):
Promise
<
any
>
{
...
...
@@ -524,8 +456,7 @@ export class ReferenceWidget extends PeekViewWidget {
dom
.
addClass
(
this
.
container
,
'
results-loaded
'
);
dom
.
show
(
this
.
_treeContainer
);
dom
.
show
(
this
.
_previewContainer
);
this
.
_preview
.
layout
();
this
.
_tree
.
layout
();
this
.
_splitView
.
layout
(
this
.
_dim
.
width
);
this
.
focus
();
// pick input and a reference to begin with
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录