Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
50807c9e
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,发现更多精彩内容 >>
提交
50807c9e
编写于
4月 28, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
scale suggest widget with editor's font size
fixes #2465
上级
45650d7b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
49 deletion
+43
-49
src/vs/editor/contrib/suggest/browser/suggest.css
src/vs/editor/contrib/suggest/browser/suggest.css
+2
-5
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
+41
-44
未找到文件。
src/vs/editor/contrib/suggest/browser/suggest.css
浏览文件 @
50807c9e
...
...
@@ -6,7 +6,7 @@
/* Suggest */
.monaco-editor
.suggest-widget
{
background-color
:
#F3F3F3
;
font-size
:
12px
;
font-size
:
90%
;
border
:
1px
solid
rgb
(
200
,
200
,
200
);
z-index
:
40
;
}
...
...
@@ -18,10 +18,6 @@
transition
:
left
.05s
ease-in-out
;
}
.monaco-editor.mac
.suggest-widget
{
font-size
:
11px
;
}
.monaco-editor.mac
.suggest-widget
.text
{
line-height
:
1.3em
;
}
...
...
@@ -83,6 +79,7 @@
.monaco-editor
.suggest-widget
.details
>
.monaco-scrollable-element
>
.body
>
.docs
,
.monaco-editor
.suggest-widget
.monaco-list
.monaco-list-row
.docs
{
color
:
#A21B1B
;
font-size
:
0.9em
;
}
.monaco-editor
.suggest-widget
.details
>
.monaco-scrollable-element
>
.body
>
.docs
,
...
...
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
浏览文件 @
50807c9e
...
...
@@ -120,28 +120,6 @@ class Renderer implements IRenderer<CompletionItem, ISuggestionTemplateData> {
}
}
const
FocusHeight
=
35
;
const
UnfocusedHeight
=
19
;
class
Delegate
implements
IDelegate
<
CompletionItem
>
{
constructor
(
private
listProvider
:
()
=>
List
<
CompletionItem
>
)
{
}
getHeight
(
element
:
CompletionItem
):
number
{
const
focus
=
this
.
listProvider
().
getFocus
()[
0
];
if
(
element
.
suggestion
.
documentationLabel
&&
element
===
focus
)
{
return
FocusHeight
;
}
return
UnfocusedHeight
;
}
getTemplateId
(
element
:
CompletionItem
):
string
{
return
'
suggestion
'
;
}
}
function
computeScore
(
suggestion
:
string
,
currentWord
:
string
,
currentWordLowerCase
:
string
):
number
{
const
suggestionLowerCase
=
suggestion
.
toLowerCase
();
let
score
=
0
;
...
...
@@ -266,7 +244,7 @@ class SuggestionDetails {
}
}
export
class
SuggestWidget
implements
IContentWidget
,
IDisposable
{
export
class
SuggestWidget
implements
IContentWidget
,
ID
elegate
<
CompletionItem
>
,
ID
isposable
{
static
ID
:
string
=
'
editor.widget.suggestWidget
'
;
static
WIDTH
:
number
=
438
;
...
...
@@ -274,7 +252,7 @@ export class SuggestWidget implements IContentWidget, IDisposable {
static
LOADING_MESSAGE
:
string
=
nls
.
localize
(
'
suggestWidget.loading
'
,
"
Loading...
"
);
static
NO_SUGGESTIONS_MESSAGE
:
string
=
nls
.
localize
(
'
suggestWidget.noSuggestions
'
,
"
No suggestions.
"
);
public
allowEditorOverflow
:
boolean
=
true
;
// Editor.IContentWidget.allowEditorOverflow
allowEditorOverflow
:
boolean
=
true
;
// Editor.IContentWidget.allowEditorOverflow
private
state
:
State
;
private
isAuto
:
boolean
;
...
...
@@ -293,7 +271,6 @@ export class SuggestWidget implements IContentWidget, IDisposable {
private
messageElement
:
HTMLElement
;
private
listElement
:
HTMLElement
;
private
details
:
SuggestionDetails
;
private
delegate
:
IDelegate
<
CompletionItem
>
;
private
list
:
List
<
CompletionItem
>
;
private
editorBlurTimeout
:
TPromise
<
void
>
;
...
...
@@ -301,7 +278,7 @@ export class SuggestWidget implements IContentWidget, IDisposable {
private
toDispose
:
IDisposable
[];
private
_onDidVisibilityChange
:
Emitter
<
boolean
>
=
new
Emitter
();
public
get
onDidVisibilityChange
():
Event
<
boolean
>
{
return
this
.
_onDidVisibilityChange
.
event
;
}
get
onDidVisibilityChange
():
Event
<
boolean
>
{
return
this
.
_onDidVisibilityChange
.
event
;
}
constructor
(
private
editor
:
ICodeEditor
,
...
...
@@ -332,8 +309,7 @@ export class SuggestWidget implements IContentWidget, IDisposable {
let
renderer
:
IRenderer
<
CompletionItem
,
any
>
=
instantiationService
.
createInstance
(
Renderer
,
this
);
this
.
delegate
=
new
Delegate
(()
=>
this
.
list
);
this
.
list
=
new
List
(
this
.
listElement
,
this
.
delegate
,
[
renderer
]);
this
.
list
=
new
List
(
this
.
listElement
,
this
,
[
renderer
]);
this
.
toDispose
=
[
editor
.
addListener2
(
EventType
.
ModelChanged
,
()
=>
this
.
onModelModeChanged
()),
...
...
@@ -641,7 +617,7 @@ export class SuggestWidget implements IContentWidget, IDisposable {
}
}
public
selectNextPage
():
boolean
{
selectNextPage
():
boolean
{
switch
(
this
.
state
)
{
case
State
.
Hidden
:
return
false
;
...
...
@@ -656,7 +632,7 @@ export class SuggestWidget implements IContentWidget, IDisposable {
}
}
public
selectNext
():
boolean
{
selectNext
():
boolean
{
switch
(
this
.
state
)
{
case
State
.
Hidden
:
return
false
;
...
...
@@ -671,7 +647,7 @@ export class SuggestWidget implements IContentWidget, IDisposable {
}
}
public
selectPreviousPage
():
boolean
{
selectPreviousPage
():
boolean
{
switch
(
this
.
state
)
{
case
State
.
Hidden
:
return
false
;
...
...
@@ -686,7 +662,7 @@ export class SuggestWidget implements IContentWidget, IDisposable {
}
}
public
selectPrevious
():
boolean
{
selectPrevious
():
boolean
{
switch
(
this
.
state
)
{
case
State
.
Hidden
:
return
false
;
...
...
@@ -701,7 +677,7 @@ export class SuggestWidget implements IContentWidget, IDisposable {
}
}
public
acceptSelectedSuggestion
():
boolean
{
acceptSelectedSuggestion
():
boolean
{
switch
(
this
.
state
)
{
case
State
.
Hidden
:
return
false
;
...
...
@@ -718,7 +694,7 @@ export class SuggestWidget implements IContentWidget, IDisposable {
}
}
public
toggleDetails
():
void
{
toggleDetails
():
void
{
if
(
this
.
state
===
State
.
Details
)
{
this
.
setState
(
State
.
Open
);
this
.
editor
.
focus
();
...
...
@@ -753,7 +729,7 @@ export class SuggestWidget implements IContentWidget, IDisposable {
removeClass
(
this
.
element
,
'
visible
'
);
}
public
cancel
():
void
{
cancel
():
void
{
if
(
this
.
state
===
State
.
Details
)
{
this
.
toggleDetails
();
}
else
{
...
...
@@ -761,7 +737,7 @@ export class SuggestWidget implements IContentWidget, IDisposable {
}
}
public
getPosition
():
IContentWidgetPosition
{
getPosition
():
IContentWidgetPosition
{
if
(
this
.
state
===
State
.
Hidden
)
{
return
null
;
}
...
...
@@ -772,11 +748,11 @@ export class SuggestWidget implements IContentWidget, IDisposable {
};
}
public
getDomNode
():
HTMLElement
{
getDomNode
():
HTMLElement
{
return
this
.
element
;
}
public
getId
():
string
{
getId
():
string
{
return
SuggestWidget
.
ID
;
}
...
...
@@ -789,16 +765,16 @@ export class SuggestWidget implements IContentWidget, IDisposable {
let
height
=
0
;
if
(
this
.
state
===
State
.
Empty
||
this
.
state
===
State
.
Loading
)
{
height
=
Unfocused
Height
;
height
=
this
.
line
Height
;
}
else
if
(
this
.
state
===
State
.
Details
)
{
height
=
12
*
Unfocused
Height
;
height
=
12
*
this
.
line
Height
;
}
else
{
const
focus
=
this
.
list
.
getFocus
()[
0
];
const
focusHeight
=
focus
?
this
.
delegate
.
getHeight
(
focus
)
:
Unfocused
Height
;
const
focusHeight
=
focus
?
this
.
getHeight
(
focus
)
:
this
.
line
Height
;
height
=
focusHeight
;
const
suggestionCount
=
(
this
.
list
.
contentHeight
-
focusHeight
)
/
Unfocused
Height
;
height
+=
Math
.
min
(
suggestionCount
,
11
)
*
Unfocused
Height
;
const
suggestionCount
=
(
this
.
list
.
contentHeight
-
focusHeight
)
/
this
.
line
Height
;
height
+=
Math
.
min
(
suggestionCount
,
11
)
*
this
.
line
Height
;
}
this
.
element
.
style
.
height
=
height
+
'
px
'
;
...
...
@@ -816,7 +792,28 @@ export class SuggestWidget implements IContentWidget, IDisposable {
}
}
public
dispose
():
void
{
// IDelegate
private
get
lineHeight
():
number
{
const
{
fontSize
}
=
this
.
editor
.
getConfiguration
();
return
Math
.
floor
(
fontSize
*
1.7
);
}
getHeight
(
element
:
CompletionItem
):
number
{
const
focus
=
this
.
list
.
getFocus
()[
0
];
if
(
element
.
suggestion
.
documentationLabel
&&
element
===
focus
)
{
return
Math
.
floor
(
this
.
lineHeight
*
1.7
);
}
return
this
.
lineHeight
;
}
getTemplateId
(
element
:
CompletionItem
):
string
{
return
'
suggestion
'
;
}
dispose
():
void
{
this
.
state
=
null
;
this
.
suggestionSupportsAutoAccept
=
null
;
this
.
currentSuggestionDetails
=
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录