Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
992f38c0
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,发现更多精彩内容 >>
未验证
提交
992f38c0
编写于
9月 24, 2019
作者:
P
Pine
提交者:
GitHub
9月 24, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #81198 from microsoft/pine/suggestFocus
Allow selection on completion detail. Fix #55853
上级
841b3360
ab49b9ba
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
53 addition
and
7 deletion
+53
-7
src/vs/editor/contrib/suggest/suggestController.ts
src/vs/editor/contrib/suggest/suggestController.ts
+22
-2
src/vs/editor/contrib/suggest/suggestWidget.ts
src/vs/editor/contrib/suggest/suggestWidget.ts
+28
-5
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
+3
-0
未找到文件。
src/vs/editor/contrib/suggest/suggestController.ts
浏览文件 @
992f38c0
...
...
@@ -6,7 +6,7 @@
import
{
alert
}
from
'
vs/base/browser/ui/aria/aria
'
;
import
{
isNonEmptyArray
}
from
'
vs/base/common/arrays
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeyCode
,
KeyMod
,
SimpleKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
dispose
,
IDisposable
,
DisposableStore
,
toDisposable
,
MutableDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
EditorAction
,
EditorCommand
,
registerEditorAction
,
registerEditorCommand
,
registerEditorContribution
,
ServicesAccessor
}
from
'
vs/editor/browser/editorExtensions
'
;
...
...
@@ -36,8 +36,13 @@ import { CommitCharacterController } from './suggestCommitCharacters';
import
{
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
TrackedRangeStickiness
,
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
const
_sticky
=
false
;
// for development purposes only
/**
* Stop suggest widget from disappearing when clicking into other areas
* For development purpose only
*/
const
_sticky
=
false
;
class
LineSuffix
{
...
...
@@ -180,6 +185,21 @@ export class SuggestController implements IEditorContribution {
}
}));
this
.
_toDispose
.
add
(
this
.
_widget
.
getValue
().
onDetailsKeyDown
(
e
=>
{
// cmd + c on macOS, ctrl + c on Win / Linux
if
(
e
.
toKeybinding
().
equals
(
new
SimpleKeybinding
(
true
,
false
,
false
,
false
,
KeyCode
.
KEY_C
))
||
(
platform
.
isMacintosh
&&
e
.
toKeybinding
().
equals
(
new
SimpleKeybinding
(
false
,
false
,
false
,
true
,
KeyCode
.
KEY_C
)))
)
{
e
.
stopPropagation
();
return
;
}
if
(
!
e
.
toKeybinding
().
isModifierKey
())
{
this
.
_editor
.
focus
();
}
}));
// Manage the acceptSuggestionsOnEnter context key
let
acceptSuggestionsOnEnter
=
SuggestContext
.
AcceptSuggestionsOnEnter
.
bindTo
(
_contextKeyService
);
let
updateFromConfig
=
()
=>
{
...
...
src/vs/editor/contrib/suggest/suggestWidget.ts
浏览文件 @
992f38c0
...
...
@@ -10,14 +10,14 @@ import * as strings from 'vs/base/common/strings';
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
IDisposable
,
dispose
,
toDisposable
,
DisposableStore
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
addClass
,
append
,
$
,
hide
,
removeClass
,
show
,
toggleClass
,
getDomNodePagePosition
,
hasClass
,
addDisposableListener
}
from
'
vs/base/browser/dom
'
;
import
{
addClass
,
append
,
$
,
hide
,
removeClass
,
show
,
toggleClass
,
getDomNodePagePosition
,
hasClass
,
addDisposableListener
,
addStandardDisposableListener
}
from
'
vs/base/browser/dom
'
;
import
{
IListVirtualDelegate
,
IListEvent
,
IListRenderer
,
IListMouseEvent
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
List
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
{
DomScrollableElement
}
from
'
vs/base/browser/ui/scrollbar/scrollableElement
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ConfigurationChangedEvent
,
EditorOption
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
ContentWidgetPositionPreference
,
ICodeEditor
,
IContentWidget
,
IContentWidgetPosition
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ContentWidgetPositionPreference
,
ICodeEditor
,
IContentWidget
,
IContentWidgetPosition
,
IEditorMouseEvent
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Context
as
SuggestContext
,
CompletionItem
}
from
'
./suggest
'
;
import
{
CompletionModel
}
from
'
./completionModel
'
;
import
{
alert
}
from
'
vs/base/browser/ui/aria/aria
'
;
...
...
@@ -39,6 +39,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
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
'
;
const
expandSuggestionDocsByDefault
=
false
;
...
...
@@ -159,7 +160,6 @@ class Renderer implements IListRenderer<CompletionItem, ISuggestionTemplateData>
data
.
icon
.
className
=
'
icon
'
+
completionKindToCssClass
(
suggestion
.
kind
);
data
.
colorspan
.
style
.
backgroundColor
=
''
;
const
labelOptions
:
IIconLabelValueOptions
=
{
labelEscapeNewLines
:
true
,
matches
:
createMatches
(
element
.
score
)
...
...
@@ -337,6 +337,8 @@ class SuggestionDetails {
}
this
.
el
.
style
.
height
=
this
.
header
.
offsetHeight
+
this
.
docs
.
offsetHeight
+
(
this
.
borderWidth
*
2
)
+
'
px
'
;
this
.
el
.
style
.
userSelect
=
'
text
'
;
this
.
el
.
tabIndex
=
-
1
;
this
.
close
.
onmousedown
=
e
=>
{
e
.
preventDefault
();
...
...
@@ -427,7 +429,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
// Editor.IContentWidget.allowEditorOverflow
readonly
allowEditorOverflow
=
true
;
readonly
suppressMouseDown
=
tru
e
;
readonly
suppressMouseDown
=
fals
e
;
private
state
:
State
|
null
=
null
;
private
isAuto
:
boolean
=
false
;
...
...
@@ -472,6 +474,9 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
private
docsPositionPreviousWidgetY
:
number
|
null
=
null
;
private
explainMode
:
boolean
=
false
;
private
readonly
_onDetailsKeydown
=
new
Emitter
<
IKeyboardEvent
>
();
public
readonly
onDetailsKeyDown
:
Event
<
IKeyboardEvent
>
=
this
.
_onDetailsKeydown
.
event
;
constructor
(
private
readonly
editor
:
ICodeEditor
,
@
ITelemetryService
private
readonly
telemetryService
:
ITelemetryService
,
...
...
@@ -525,7 +530,6 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
this
.
toDispose
.
add
(
this
.
editor
.
onDidChangeCursorSelection
(()
=>
this
.
onCursorSelectionChanged
()));
this
.
toDispose
.
add
(
this
.
editor
.
onDidChangeConfiguration
(
e
=>
e
.
hasChanged
(
EditorOption
.
suggest
)
&&
applyIconStyle
()));
this
.
suggestWidgetVisible
=
SuggestContext
.
Visible
.
bindTo
(
contextKeyService
);
this
.
suggestWidgetMultipleSuggestions
=
SuggestContext
.
MultipleSuggestions
.
bindTo
(
contextKeyService
);
...
...
@@ -533,6 +537,25 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
this
.
setState
(
State
.
Hidden
);
this
.
onThemeChange
(
themeService
.
getTheme
());
this
.
toDispose
.
add
(
addStandardDisposableListener
(
this
.
details
.
element
,
'
keydown
'
,
e
=>
{
this
.
_onDetailsKeydown
.
fire
(
e
);
}));
this
.
toDispose
.
add
(
this
.
editor
.
onMouseDown
((
e
:
IEditorMouseEvent
)
=>
this
.
onEditorMouseDown
(
e
)));
}
private
onEditorMouseDown
(
mouseEvent
:
IEditorMouseEvent
):
void
{
// Clicking inside details
if
(
this
.
details
.
element
.
contains
(
mouseEvent
.
target
.
element
))
{
this
.
details
.
element
.
focus
();
}
// Clicking outside details and inside suggest
else
{
if
(
this
.
element
.
contains
(
mouseEvent
.
target
.
element
))
{
this
.
editor
.
focus
();
}
}
}
private
onCursorSelectionChanged
():
void
{
...
...
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
浏览文件 @
992f38c0
...
...
@@ -30,6 +30,8 @@ import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtil
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
ISuggestMemoryService
}
from
'
vs/editor/contrib/suggest/suggestMemory
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
MockKeybindingService
}
from
'
vs/platform/keybinding/test/common/mockKeybindingService
'
;
export
interface
Ctor
<
T
>
{
new
():
T
;
...
...
@@ -46,6 +48,7 @@ function createMockEditor(model: TextModel): TestCodeEditor {
serviceCollection
:
new
ServiceCollection
(
[
ITelemetryService
,
NullTelemetryService
],
[
IStorageService
,
new
InMemoryStorageService
()],
[
IKeybindingService
,
new
MockKeybindingService
()],
[
ISuggestMemoryService
,
new
class
implements
ISuggestMemoryService
{
_serviceBrand
:
undefined
;
memorize
():
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录