Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
70b0382e
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,发现更多精彩内容 >>
提交
70b0382e
编写于
1月 24, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update statusbar with "real" keybindings
上级
d413a30a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
51 addition
and
29 deletion
+51
-29
src/vs/editor/contrib/suggest/suggestController.ts
src/vs/editor/contrib/suggest/suggestController.ts
+17
-13
src/vs/editor/contrib/suggest/suggestWidget.ts
src/vs/editor/contrib/suggest/suggestWidget.ts
+34
-16
未找到文件。
src/vs/editor/contrib/suggest/suggestController.ts
浏览文件 @
70b0382e
...
...
@@ -528,11 +528,8 @@ const SuggestCommand = EditorCommand.bindToContribution<SuggestController>(Sugge
registerEditorCommand
(
new
SuggestCommand
({
id
:
'
acceptSelectedSuggestion
'
,
precondition
:
SuggestContext
.
Visible
,
handler
(
x
,
args
)
{
const
alternative
:
boolean
=
typeof
args
===
'
object
'
&&
typeof
args
.
alternative
===
'
boolean
'
?
args
.
alternative
:
false
;
x
.
acceptSelectedSuggestion
(
true
,
alternative
);
handler
(
x
)
{
x
.
acceptSelectedSuggestion
(
true
,
false
);
}
}));
...
...
@@ -552,16 +549,23 @@ KeybindingsRegistry.registerKeybindingRule({
weight
});
// todo@joh control enablement via context key
// shift+enter and shift+tab use the alternative-flag so that the suggest controller
// is doing the opposite of the editor.suggest.overwriteOnAccept-configuration
KeybindingsRegistry
.
registerKeybindingRule
({
id
:
'
acceptSelectedSuggestion
'
,
when
:
ContextKeyExpr
.
and
(
SuggestContext
.
Visible
,
EditorContextKeys
.
textInputFocus
),
primary
:
KeyMod
.
Shift
|
KeyCode
.
Tab
,
secondary
:
[
KeyMod
.
Shift
|
KeyCode
.
Enter
],
args
:
{
alternative
:
true
},
weight
});
registerEditorCommand
(
new
SuggestCommand
({
id
:
'
acceptAlternativeSelectedSuggestion
'
,
precondition
:
ContextKeyExpr
.
and
(
SuggestContext
.
Visible
,
EditorContextKeys
.
textInputFocus
),
kbOpts
:
{
weight
:
weight
,
kbExpr
:
EditorContextKeys
.
textInputFocus
,
primary
:
KeyMod
.
Shift
|
KeyCode
.
Enter
,
secondary
:
[
KeyMod
.
Shift
|
KeyCode
.
Tab
],
},
handler
(
x
)
{
x
.
acceptSelectedSuggestion
(
false
,
true
);
},
}));
// continue to support the old command
CommandsRegistry
.
registerCommandAlias
(
'
acceptSelectedSuggestionOnEnter
'
,
'
acceptSelectedSuggestion
'
);
...
...
src/vs/editor/contrib/suggest/suggestWidget.ts
浏览文件 @
70b0382e
...
...
@@ -42,13 +42,10 @@ import { FileKind } from 'vs/platform/files/common/files';
import
{
MarkdownString
}
from
'
vs/base/common/htmlContent
'
;
import
{
flatten
}
from
'
vs/base/common/arrays
'
;
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
const
expandSuggestionDocsByDefault
=
false
;
const
READ_MORE_TEXT
=
nls
.
localize
(
'
suggestWidget.readMore
'
,
'
Read more... (⌃Space)
'
);
const
READ_LESS_TEXT
=
nls
.
localize
(
'
suggestWidget.readLess
'
,
'
Read less... (⌃Space)
'
);
const
INSERT_REPLACE_TEXT
=
nls
.
localize
(
'
suggestWidget.insertOrReplace
'
,
'
Enter to insert, Tab to replace
'
);
interface
ISuggestionTemplateData
{
root
:
HTMLElement
;
...
...
@@ -306,7 +303,7 @@ class SuggestionDetails {
private
readonly
widget
:
SuggestWidget
,
private
readonly
editor
:
ICodeEditor
,
private
readonly
markdownRenderer
:
MarkdownRenderer
,
private
readonly
triggerKeybindingLabel
:
string
,
private
readonly
kbToggleDetails
:
string
,
)
{
this
.
disposables
=
new
DisposableStore
();
...
...
@@ -321,7 +318,7 @@ class SuggestionDetails {
this
.
header
=
append
(
this
.
body
,
$
(
'
.header
'
));
this
.
close
=
append
(
this
.
header
,
$
(
'
span.codicon.codicon-close
'
));
this
.
close
.
title
=
nls
.
localize
(
'
readLess
'
,
"
Read less...{0}
"
,
this
.
triggerKeybindingLabel
);
this
.
close
.
title
=
nls
.
localize
(
'
readLess
'
,
"
Read less...{0}
"
,
this
.
kbToggleDetails
);
this
.
type
=
append
(
this
.
header
,
$
(
'
p.type
'
));
this
.
docs
=
append
(
this
.
body
,
$
(
'
p.docs
'
));
...
...
@@ -473,6 +470,9 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
readonly
allowEditorOverflow
=
true
;
readonly
suppressMouseDown
=
false
;
private
readonly
msgDetailMore
:
string
;
private
readonly
msgDetailsLess
:
string
;
private
state
:
State
|
null
=
null
;
private
isAuto
:
boolean
=
false
;
private
loadingTimeout
:
IDisposable
=
Disposable
.
None
;
...
...
@@ -525,18 +525,20 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
constructor
(
private
readonly
editor
:
ICodeEditor
,
@
ITelemetryService
private
readonly
telemetryService
:
ITelemetryService
,
@
IKeybindingService
private
readonly
keybindingService
:
IKeybindingService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IThemeService
themeService
:
IThemeService
,
@
IStorageService
storageService
:
IStorageService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
IModeService
modeService
:
IModeService
,
@
IOpenerService
openerService
:
IOpenerService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
)
{
const
kb
=
keybindingService
.
lookupKeybinding
(
'
editor.action.triggerSuggest
'
);
const
triggerKeybindingLabel
=
!
kb
?
''
:
` (
${
kb
.
getLabel
()}
)`
;
const
markdownRenderer
=
this
.
toDispose
.
add
(
new
MarkdownRenderer
(
editor
,
modeService
,
openerService
));
const
kbToggleDetails
=
keybindingService
.
lookupKeybinding
(
'
toggleSuggestionDetails
'
)?.
getLabel
()
??
''
;
this
.
msgDetailsLess
=
nls
.
localize
(
'
detail.less
'
,
"
{0} for less...
"
,
kbToggleDetails
);
this
.
msgDetailMore
=
nls
.
localize
(
'
detail.more
'
,
"
{0} for more...
"
,
kbToggleDetails
);
this
.
isAuto
=
false
;
this
.
focusedItem
=
null
;
this
.
storageService
=
storageService
;
...
...
@@ -558,15 +560,15 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
this
.
statusBarLeftSpan
=
append
(
this
.
statusBarElement
,
$
(
'
span
'
));
this
.
statusBarRightSpan
=
append
(
this
.
statusBarElement
,
$
(
'
span
'
));
this
.
setStatusBarLeftText
(
INSERT_REPLACE_TEXT
);
this
.
setStatusBarLeftText
(
''
);
this
.
setStatusBarRightText
(
''
);
this
.
details
=
instantiationService
.
createInstance
(
SuggestionDetails
,
this
.
element
,
this
,
this
.
editor
,
markdownRenderer
,
triggerKeybindingLabel
);
this
.
details
=
instantiationService
.
createInstance
(
SuggestionDetails
,
this
.
element
,
this
,
this
.
editor
,
markdownRenderer
,
kbToggleDetails
);
const
applyIconStyle
=
()
=>
toggleClass
(
this
.
element
,
'
no-icons
'
,
!
this
.
editor
.
getOption
(
EditorOption
.
suggest
).
showIcons
);
applyIconStyle
();
let
renderer
=
instantiationService
.
createInstance
(
ItemRenderer
,
this
,
this
.
editor
,
triggerKeybindingLabel
);
let
renderer
=
instantiationService
.
createInstance
(
ItemRenderer
,
this
,
this
.
editor
,
kbToggleDetails
);
this
.
list
=
new
List
(
'
SuggestWidget
'
,
this
.
listElement
,
this
,
[
renderer
],
{
useShadows
:
false
,
...
...
@@ -730,6 +732,22 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
this
.
firstFocusInCurrentList
=
!
this
.
focusedItem
;
if
(
item
!==
this
.
focusedItem
)
{
// update statusbar
// todo@joh,pine -> this should a toolbar with actions so that these things become
// mouse clickable and fit for accessibility...
const
wantsInsert
=
this
.
editor
.
getOption
(
EditorOption
.
suggest
).
insertMode
===
'
insert
'
;
const
kbAccept
=
this
.
keybindingService
.
lookupKeybinding
(
'
acceptSelectedSuggestion
'
)?.
getLabel
();
const
kbAcceptAlt
=
this
.
keybindingService
.
lookupKeybinding
(
'
acceptAlternativeSelectedSuggestion
'
)?.
getLabel
();
if
(
!
Position
.
equals
(
item
.
editInsertEnd
,
item
.
editReplaceEnd
))
{
// insert AND replace
if
(
wantsInsert
)
{
this
.
setStatusBarLeftText
(
nls
.
localize
(
'
insert
'
,
"
{0} to insert, {1} to replace
"
,
kbAccept
,
kbAcceptAlt
));
}
else
{
this
.
setStatusBarLeftText
(
nls
.
localize
(
'
replace
'
,
"
{0} to replace, {1} to insert
"
,
kbAccept
,
kbAcceptAlt
));
}
}
else
{
this
.
setStatusBarLeftText
(
nls
.
localize
(
'
accept
'
,
"
{0} to accept
"
,
kbAccept
));
}
if
(
this
.
currentSuggestionDetails
)
{
this
.
currentSuggestionDetails
.
cancel
();
...
...
@@ -767,9 +785,9 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
if
(
canExpandCompletionItem
(
this
.
focusedItem
))
{
if
(
this
.
expandDocsSettingFromStorage
())
{
this
.
setStatusBarRightText
(
READ_LESS_TEXT
);
this
.
setStatusBarRightText
(
this
.
msgDetailsLess
);
}
else
{
this
.
setStatusBarRightText
(
READ_MORE_TEXT
);
this
.
setStatusBarRightText
(
this
.
msgDetailMore
);
}
}
else
{
this
.
statusBarRightSpan
.
innerText
=
''
;
...
...
@@ -1044,7 +1062,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
removeClass
(
this
.
element
,
'
docs-side
'
);
removeClass
(
this
.
element
,
'
docs-below
'
);
this
.
editor
.
layoutContentWidget
(
this
);
this
.
setStatusBarRightText
(
READ_MORE_TEXT
);
this
.
setStatusBarRightText
(
this
.
msgDetailMore
);
this
.
telemetryService
.
publicLog2
(
'
suggestWidget:collapseDetails
'
);
}
else
{
if
(
this
.
state
!==
State
.
Open
&&
this
.
state
!==
State
.
Details
&&
this
.
state
!==
State
.
Frozen
)
{
...
...
@@ -1053,7 +1071,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
this
.
updateExpandDocsSetting
(
true
);
this
.
showDetails
(
false
);
this
.
setStatusBarRightText
(
READ_LESS_TEXT
);
this
.
setStatusBarRightText
(
this
.
msgDetailsLess
);
this
.
telemetryService
.
publicLog2
(
'
suggestWidget:expandDetails
'
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录