Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
bf53bb08
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
bf53bb08
编写于
5月 08, 2017
作者:
R
Ramya Rao
提交者:
GitHub
5月 08, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use EditorGroupinfo to decide if to swap/reposition suggest widget (#26250)
上级
05c3876f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
66 deletion
+34
-66
src/vs/editor/contrib/suggest/browser/media/suggest.css
src/vs/editor/contrib/suggest/browser/media/suggest.css
+0
-2
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
+34
-64
未找到文件。
src/vs/editor/contrib/suggest/browser/media/suggest.css
浏览文件 @
bf53bb08
...
...
@@ -23,7 +23,6 @@
.monaco-editor
.suggest-widget
>
.tree
{
height
:
100%
;
width
:
220px
;
float
:
left
;
box-sizing
:
border-box
;
}
...
...
@@ -114,7 +113,6 @@
flex-direction
:
column
;
cursor
:
default
;
box-sizing
:
border-box
;
width
:
440px
;
}
.monaco-editor
.suggest-widget
.details.no-docs
{
...
...
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
浏览文件 @
bf53bb08
...
...
@@ -31,6 +31,7 @@ import { attachListStyler } from 'vs/platform/theme/common/styler';
import
{
IThemeService
,
ITheme
,
registerThemingParticipant
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
registerColor
,
editorWidgetBackground
,
contrastBorder
,
listFocusBackground
,
activeContrastBorder
,
listHighlightForeground
,
editorForeground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
const
sticky
=
false
;
// for development purposes
...
...
@@ -308,19 +309,18 @@ export class SuggestWidget implements IContentWidget, IDelegate<ICompletionItem>
readonly
onDidShow
:
Event
<
this
>
=
this
.
onDidShowEmitter
.
event
;
private
preferredPosition
:
Position
;
private
readonly
minWidgetWidth
=
440
;
private
readonly
maxWidgetWidth
=
660
;
private
readonly
listWidth
=
220
;
private
readonly
minDocsWidth
=
220
;
private
readonly
maxDocsWidth
=
440
;
private
readonly
widgetWidthInSmallestEditor
=
300
;
private
readonly
listWidth
=
330
;
private
readonly
docsWidth
=
330
;
private
readonly
minWidgetWidth
=
400
;
constructor
(
private
editor
:
ICodeEditor
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IThemeService
themeService
:
IThemeService
@
IThemeService
themeService
:
IThemeService
,
@
IEditorGroupService
private
editorGroupService
:
IEditorGroupService
)
{
this
.
isAuto
=
false
;
this
.
focusedItem
=
null
;
...
...
@@ -830,89 +830,59 @@ export class SuggestWidget implements IContentWidget, IDelegate<ICompletionItem>
if
(
this
.
messageElement
.
style
.
display
!==
'
none
'
&&
this
.
details
.
element
.
style
.
display
===
'
none
'
&&
this
.
listElement
.
style
.
display
===
'
none
'
)
{
this
.
element
.
style
.
width
=
`
${
this
.
widgetWidthInSmallestEditor
}
px`
;
this
.
element
.
style
.
width
=
`
${
this
.
minWidgetWidth
}
px`
;
return
;
}
const
perColumnWidth
=
this
.
editor
.
getLayoutInfo
().
contentWidth
/
this
.
editor
.
getLayoutInfo
().
viewportColumn
;
const
spaceOntheLeft
=
Math
.
floor
(
this
.
editor
.
getPosition
().
column
*
perColumnWidth
)
-
this
.
editor
.
getScrollLeft
();
const
spaceOntheRight
=
this
.
editor
.
getLayoutInfo
().
contentWidth
-
spaceOntheLeft
;
const
scrolledColumns
=
Math
.
floor
(
this
.
editor
.
getScrollLeft
()
/
perColumnWidth
);
const
columnsOccupiedByDocs
=
Math
.
floor
(
this
.
docsWidth
/
perColumnWidth
);
// Reset width
this
.
details
.
element
.
style
.
width
=
`
${
this
.
maxD
ocsWidth
}
px`
;
this
.
details
.
element
.
style
.
width
=
`
${
this
.
d
ocsWidth
}
px`
;
this
.
element
.
style
.
width
=
`
${
this
.
maxWidgetWidth
}
px`
;
this
.
listElement
.
style
.
width
=
`
${
this
.
listWidth
}
px`
;
if
(
spaceOntheRight
>
this
.
maxWidgetWidth
)
{
// There is enough space on the right, so nothing to do here.
return
;
}
let
editorStacksModel
=
this
.
editorGroupService
.
getStacksModel
();
let
totalEditors
=
editorStacksModel
.
groups
.
length
;
let
currentEditorPosition
=
editorStacksModel
.
positionOfGroup
(
editorStacksModel
.
activeGroup
);
if
(
spaceOntheRight
>
this
.
minWidgetWidth
)
{
// There is enough space on the right for list and resized docs
this
.
adjustDocs
(
false
,
spaceOntheRight
-
this
.
listWidth
,
this
.
editor
.
getPosition
().
column
);
if
(
spaceOntheRight
>
this
.
maxWidgetWidth
||
(
this
.
editorGroupService
.
getGroupOrientation
()
===
'
vertical
'
&&
currentEditorPosition
<
totalEditors
-
1
))
{
// There is enough space on the right, so nothing to do here.
return
;
}
if
(
spaceOntheRight
>
this
.
listWidth
&&
spaceOntheLeft
>
this
.
maxDocsWidth
)
{
// Docs on the left and list on the right of the cursor
let
columnsOccupiedByDocs
=
Math
.
floor
(
this
.
maxDocsWidth
/
perColumnWidth
);
this
.
adjustDocs
(
true
,
null
,
this
.
editor
.
getPosition
().
column
-
columnsOccupiedByDocs
);
if
(
this
.
editorGroupService
.
getGroupOrientation
()
===
'
horizontal
'
||
totalEditors
===
1
)
{
if
(
this
.
editor
.
getLayoutInfo
().
contentWidth
>
this
.
maxWidgetWidth
)
{
if
(
spaceOntheRight
<
this
.
docsWidth
)
{
addClass
(
this
.
element
,
'
list-right
'
);
this
.
preferredPosition
=
new
Position
(
this
.
editor
.
getPosition
().
lineNumber
,
this
.
editor
.
getPosition
().
column
-
columnsOccupiedByDocs
);
}
return
;
}
this
.
showDocsBelow
();
return
;
}
if
(
spaceOntheRight
>
this
.
listWidth
&&
spaceOntheLeft
>
this
.
minDocsWidth
)
{
// Resized docs on the left and list on the right of the cursor
let
columnsOccupiedByDocs
=
Math
.
floor
(
spaceOntheLeft
/
perColumnWidth
);
this
.
adjustDocs
(
true
,
spaceOntheLeft
,
this
.
editor
.
getPosition
().
column
-
columnsOccupiedByDocs
);
return
;
}
// Its vertical, multiple editors, active editor is the last one and not enough space on the right for widget
// TODO: Check if window width < this.maxDocsWidth, in which case we may have to drop the docs below.
addClass
(
this
.
element
,
'
list-right
'
);
this
.
preferredPosition
=
new
Position
(
this
.
editor
.
getPosition
().
lineNumber
,
this
.
editor
.
getPosition
().
column
-
columnsOccupiedByDocs
);
if
(
this
.
editor
.
getLayoutInfo
().
contentWidth
>
this
.
maxWidgetWidth
)
{
// Use as much space on the right, and for the rest go left
let
columnsOccupiedByWidget
=
Math
.
floor
(
this
.
maxWidgetWidth
/
perColumnWidth
);
let
preferredColumn
=
this
.
editor
.
getLayoutInfo
().
viewportColumn
-
columnsOccupiedByWidget
+
scrolledColumns
;
this
.
adjustDocs
(
true
,
null
,
preferredColumn
);
return
;
}
if
(
this
.
editor
.
getLayoutInfo
().
contentWidth
>
this
.
minWidgetWidth
)
{
// Resize docs. Swap only of there is enough space on the right for the list
let
newDocsWidth
=
this
.
editor
.
getLayoutInfo
().
contentWidth
-
this
.
listWidth
;
this
.
adjustDocs
(
spaceOntheRight
<
this
.
listWidth
,
newDocsWidth
,
scrolledColumns
);
return
;
}
return
;
}
private
showDocsBelow
()
{
// Not enough space to show side by side
// So show docs below the list
addClass
(
this
.
element
,
'
docs-below
'
);
this
.
listElement
.
style
.
width
=
`
${
this
.
widgetWidthInSmallestEditor
}
px`
;
this
.
element
.
style
.
width
=
`
${
this
.
widgetWidthInSmallestEditor
}
px`
;
this
.
details
.
element
.
style
.
width
=
`
${
this
.
widgetWidthInSmallestEditor
}
px`
;
this
.
listElement
.
style
.
width
=
`
${
this
.
minWidgetWidth
}
px`
;
this
.
element
.
style
.
width
=
`
${
this
.
minWidgetWidth
}
px`
;
this
.
details
.
element
.
style
.
width
=
`
${
this
.
minWidgetWidth
}
px`
;
}
/**
* Adjust the width of the docs widget, swaps docs/list and moves suggest widget if needed
*
* @swap boolean If true, then the docs and list are swapped
* @resizedDocWidth number If not null, this number will be used to set the width of the docs
* @preferredColumn Preferred column in the current line for the suggest widget
*/
private
adjustDocs
(
swap
:
boolean
,
resizedDocWidth
:
number
,
preferredColumn
:
number
)
{
if
(
swap
)
{
addClass
(
this
.
element
,
'
list-right
'
);
}
if
(
resizedDocWidth
!==
null
)
{
this
.
details
.
element
.
style
.
width
=
`
${
resizedDocWidth
}
px`
;
this
.
element
.
style
.
width
=
`
${
resizedDocWidth
+
this
.
listWidth
}
px`
;
}
this
.
preferredPosition
=
new
Position
(
this
.
editor
.
getPosition
().
lineNumber
,
preferredColumn
);
}
private
renderDetails
():
void
{
if
(
this
.
state
===
State
.
Details
||
this
.
state
===
State
.
Open
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录