Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
旅途_2012
vscode
提交
118e3517
V
vscode
项目概览
旅途_2012
/
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,发现更多精彩内容 >>
提交
118e3517
编写于
7月 05, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - use DisposableStore in more places
上级
6b519e5b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
49 deletion
+41
-49
src/vs/editor/contrib/goToDefinition/goToDefinitionMouse.ts
src/vs/editor/contrib/goToDefinition/goToDefinitionMouse.ts
+7
-8
src/vs/editor/contrib/snippet/snippetController2.ts
src/vs/editor/contrib/snippet/snippetController2.ts
+7
-8
src/vs/editor/contrib/suggest/suggestCommitCharacters.ts
src/vs/editor/contrib/suggest/suggestCommitCharacters.ts
+7
-7
src/vs/editor/contrib/suggest/suggestController.ts
src/vs/editor/contrib/suggest/suggestController.ts
+20
-26
未找到文件。
src/vs/editor/contrib/goToDefinition/goToDefinitionMouse.ts
浏览文件 @
118e3517
...
...
@@ -16,7 +16,7 @@ import { DefinitionProviderRegistry, LocationLink } from 'vs/editor/common/modes
import
{
ICodeEditor
,
IMouseTarget
,
MouseTargetType
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
registerEditorContribution
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
getDefinitionsAtPosition
}
from
'
./goToDefinition
'
;
import
{
IDisposable
,
dispos
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
DisposableStor
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
registerThemingParticipant
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
editorActiveLinkForeground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
...
...
@@ -33,7 +33,7 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
static
MAX_SOURCE_PREVIEW_LINES
=
8
;
private
readonly
editor
:
ICodeEditor
;
private
toUnhook
:
IDisposable
[]
;
private
readonly
toUnhook
=
new
DisposableStore
()
;
private
decorations
:
string
[];
private
currentWordUnderMouse
:
IWordAtPosition
|
null
;
private
previousPromise
:
CancelablePromise
<
LocationLink
[]
|
null
>
|
null
;
...
...
@@ -43,19 +43,18 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
@
ITextModelService
private
readonly
textModelResolverService
:
ITextModelService
,
@
IModeService
private
readonly
modeService
:
IModeService
)
{
this
.
toUnhook
=
[];
this
.
decorations
=
[];
this
.
editor
=
editor
;
this
.
previousPromise
=
null
;
let
linkGesture
=
new
ClickLinkGesture
(
editor
);
this
.
toUnhook
.
push
(
linkGesture
);
this
.
toUnhook
.
add
(
linkGesture
);
this
.
toUnhook
.
push
(
linkGesture
.
onMouseMoveOrRelevantKeyDown
(([
mouseEvent
,
keyboardEvent
])
=>
{
this
.
toUnhook
.
add
(
linkGesture
.
onMouseMoveOrRelevantKeyDown
(([
mouseEvent
,
keyboardEvent
])
=>
{
this
.
startFindDefinition
(
mouseEvent
,
withNullAsUndefined
(
keyboardEvent
));
}));
this
.
toUnhook
.
push
(
linkGesture
.
onExecute
((
mouseEvent
:
ClickLinkMouseEvent
)
=>
{
this
.
toUnhook
.
add
(
linkGesture
.
onExecute
((
mouseEvent
:
ClickLinkMouseEvent
)
=>
{
if
(
this
.
isEnabled
(
mouseEvent
))
{
this
.
gotoDefinition
(
mouseEvent
.
target
,
mouseEvent
.
hasSideBySideModifier
).
then
(()
=>
{
this
.
removeDecorations
();
...
...
@@ -66,7 +65,7 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
}
}));
this
.
toUnhook
.
push
(
linkGesture
.
onCancel
(()
=>
{
this
.
toUnhook
.
add
(
linkGesture
.
onCancel
(()
=>
{
this
.
removeDecorations
();
this
.
currentWordUnderMouse
=
null
;
}));
...
...
@@ -303,7 +302,7 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
}
public
dispose
():
void
{
this
.
toUnhook
=
dispose
(
this
.
toUnhook
);
this
.
toUnhook
.
dispose
(
);
}
}
...
...
src/vs/editor/contrib/snippet/snippetController2.ts
浏览文件 @
118e3517
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
dispose
,
IDisposabl
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
DisposableStor
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
repeat
}
from
'
vs/base/common/strings
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
EditorCommand
,
registerEditorCommand
,
registerEditorContribution
}
from
'
vs/editor/browser/editorExtensions
'
;
...
...
@@ -35,7 +35,7 @@ export class SnippetController2 implements IEditorContribution {
private
readonly
_hasPrevTabstop
:
IContextKey
<
boolean
>
;
private
_session
?:
SnippetSession
;
private
_snippetListener
:
IDisposable
[]
=
[]
;
private
_snippetListener
=
new
DisposableStore
()
;
private
_modelVersionId
:
number
;
private
_currentChoice
?:
Choice
;
...
...
@@ -54,6 +54,7 @@ export class SnippetController2 implements IEditorContribution {
this
.
_hasPrevTabstop
.
reset
();
this
.
_hasNextTabstop
.
reset
();
dispose
(
this
.
_session
);
this
.
_snippetListener
.
dispose
();
}
getId
():
string
{
...
...
@@ -93,7 +94,7 @@ export class SnippetController2 implements IEditorContribution {
// don't listen while inserting the snippet
// as that is the inflight state causing cancelation
this
.
_snippetListener
=
dispose
(
this
.
_snippetListener
);
this
.
_snippetListener
.
clear
(
);
if
(
undoStopBefore
)
{
this
.
_editor
.
getModel
().
pushStackElement
();
...
...
@@ -113,11 +114,9 @@ export class SnippetController2 implements IEditorContribution {
this
.
_updateState
();
this
.
_snippetListener
=
[
this
.
_editor
.
onDidChangeModelContent
(
e
=>
e
.
isFlush
&&
this
.
cancel
()),
this
.
_editor
.
onDidChangeModel
(()
=>
this
.
cancel
()),
this
.
_editor
.
onDidChangeCursorSelection
(()
=>
this
.
_updateState
())
];
this
.
_snippetListener
.
add
(
this
.
_editor
.
onDidChangeModelContent
(
e
=>
e
.
isFlush
&&
this
.
cancel
()));
this
.
_snippetListener
.
add
(
this
.
_editor
.
onDidChangeModel
(()
=>
this
.
cancel
()));
this
.
_snippetListener
.
add
(
this
.
_editor
.
onDidChangeCursorSelection
(()
=>
this
.
_updateState
()));
}
private
_updateState
():
void
{
...
...
src/vs/editor/contrib/suggest/suggestCommitCharacters.ts
浏览文件 @
118e3517
...
...
@@ -4,14 +4,14 @@
*--------------------------------------------------------------------------------------------*/
import
{
isNonEmptyArray
}
from
'
vs/base/common/arrays
'
;
import
{
dispose
,
IDisposabl
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
DisposableStor
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ISelectedSuggestion
,
SuggestWidget
}
from
'
./suggestWidget
'
;
import
{
CharacterSet
}
from
'
vs/editor/common/core/characterClassifier
'
;
export
class
CommitCharacterController
{
private
_disposables
:
IDisposable
[]
=
[]
;
private
readonly
_disposables
=
new
DisposableStore
()
;
private
_active
?:
{
readonly
acceptCharacters
:
CharacterSet
;
...
...
@@ -20,11 +20,11 @@ export class CommitCharacterController {
constructor
(
editor
:
ICodeEditor
,
widget
:
SuggestWidget
,
accept
:
(
selected
:
ISelectedSuggestion
)
=>
any
)
{
this
.
_disposables
.
push
(
widget
.
onDidShow
(()
=>
this
.
_onItem
(
widget
.
getFocusedItem
())));
this
.
_disposables
.
push
(
widget
.
onDidFocus
(
this
.
_onItem
,
this
));
this
.
_disposables
.
push
(
widget
.
onDidHide
(
this
.
reset
,
this
));
this
.
_disposables
.
add
(
widget
.
onDidShow
(()
=>
this
.
_onItem
(
widget
.
getFocusedItem
())));
this
.
_disposables
.
add
(
widget
.
onDidFocus
(
this
.
_onItem
,
this
));
this
.
_disposables
.
add
(
widget
.
onDidHide
(
this
.
reset
,
this
));
this
.
_disposables
.
push
(
editor
.
onWillType
(
text
=>
{
this
.
_disposables
.
add
(
editor
.
onWillType
(
text
=>
{
if
(
this
.
_active
)
{
const
ch
=
text
.
charCodeAt
(
text
.
length
-
1
);
if
(
this
.
_active
.
acceptCharacters
.
has
(
ch
)
&&
editor
.
getConfiguration
().
contribInfo
.
acceptSuggestionOnCommitCharacter
)
{
...
...
@@ -54,6 +54,6 @@ export class CommitCharacterController {
}
dispose
()
{
dispose
(
this
.
_disposables
);
this
.
_disposables
.
dispose
(
);
}
}
src/vs/editor/contrib/suggest/suggestController.ts
浏览文件 @
118e3517
...
...
@@ -7,7 +7,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
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
IDisposable
,
DisposableStore
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
EditorAction
,
EditorCommand
,
registerEditorAction
,
registerEditorCommand
,
registerEditorContribution
,
ServicesAccessor
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
EditOperation
}
from
'
vs/editor/common/core/editOperation
'
;
...
...
@@ -45,7 +45,7 @@ export class SuggestController implements IEditorContribution {
private
readonly
_model
:
SuggestModel
;
private
readonly
_widget
:
IdleValue
<
SuggestWidget
>
;
private
readonly
_alternatives
:
IdleValue
<
SuggestAlternatives
>
;
private
_toDispose
:
IDisposable
[]
=
[]
;
private
readonly
_toDispose
=
new
DisposableStore
()
;
private
readonly
_sticky
=
false
;
// for development purposes only
...
...
@@ -63,23 +63,21 @@ export class SuggestController implements IEditorContribution {
const
widget
=
this
.
_instantiationService
.
createInstance
(
SuggestWidget
,
this
.
_editor
);
this
.
_toDispose
.
push
(
widget
);
this
.
_toDispose
.
push
(
widget
.
onDidSelect
(
item
=>
this
.
_insertSuggestion
(
item
,
false
,
true
),
this
));
this
.
_toDispose
.
add
(
widget
);
this
.
_toDispose
.
add
(
widget
.
onDidSelect
(
item
=>
this
.
_insertSuggestion
(
item
,
false
,
true
),
this
));
// Wire up logic to accept a suggestion on certain characters
const
commitCharacterController
=
new
CommitCharacterController
(
this
.
_editor
,
widget
,
item
=>
this
.
_insertSuggestion
(
item
,
false
,
true
));
this
.
_toDispose
.
push
(
commitCharacterController
,
this
.
_model
.
onDidSuggest
(
e
=>
{
if
(
e
.
completionModel
.
items
.
length
===
0
)
{
commitCharacterController
.
reset
();
}
})
);
this
.
_toDispose
.
add
(
commitCharacterController
);
this
.
_toDispose
.
add
(
this
.
_model
.
onDidSuggest
(
e
=>
{
if
(
e
.
completionModel
.
items
.
length
===
0
)
{
commitCharacterController
.
reset
();
}
}));
// Wire up makes text edit context key
let
makesTextEdit
=
SuggestContext
.
MakesTextEdit
.
bindTo
(
this
.
_contextKeyService
);
this
.
_toDispose
.
push
(
widget
.
onDidFocus
(({
item
})
=>
{
this
.
_toDispose
.
add
(
widget
.
onDidFocus
(({
item
})
=>
{
const
position
=
this
.
_editor
.
getPosition
()
!
;
const
startColumn
=
item
.
completion
.
range
.
startColumn
;
...
...
@@ -103,36 +101,32 @@ export class SuggestController implements IEditorContribution {
}
makesTextEdit
.
set
(
value
);
}));
this
.
_toDispose
.
push
({
dispose
()
{
makesTextEdit
.
reset
();
}
});
this
.
_toDispose
.
add
(
toDisposable
(()
=>
makesTextEdit
.
reset
()));
return
widget
;
});
this
.
_alternatives
=
new
IdleValue
(()
=>
{
let
res
=
new
SuggestAlternatives
(
this
.
_editor
,
this
.
_contextKeyService
);
this
.
_toDispose
.
push
(
res
);
return
res
;
return
this
.
_toDispose
.
add
(
new
SuggestAlternatives
(
this
.
_editor
,
this
.
_contextKeyService
));
});
this
.
_toDispose
.
push
(
_instantiationService
.
createInstance
(
WordContextKey
,
_editor
));
this
.
_toDispose
.
add
(
_instantiationService
.
createInstance
(
WordContextKey
,
_editor
));
this
.
_toDispose
.
push
(
this
.
_model
.
onDidTrigger
(
e
=>
{
this
.
_toDispose
.
add
(
this
.
_model
.
onDidTrigger
(
e
=>
{
this
.
_widget
.
getValue
().
showTriggered
(
e
.
auto
,
e
.
shy
?
250
:
50
);
}));
this
.
_toDispose
.
push
(
this
.
_model
.
onDidSuggest
(
e
=>
{
this
.
_toDispose
.
add
(
this
.
_model
.
onDidSuggest
(
e
=>
{
if
(
!
e
.
shy
)
{
let
index
=
this
.
_memoryService
.
select
(
this
.
_editor
.
getModel
()
!
,
this
.
_editor
.
getPosition
()
!
,
e
.
completionModel
.
items
);
this
.
_widget
.
getValue
().
showSuggestions
(
e
.
completionModel
,
index
,
e
.
isFrozen
,
e
.
auto
);
}
}));
this
.
_toDispose
.
push
(
this
.
_model
.
onDidCancel
(
e
=>
{
this
.
_toDispose
.
add
(
this
.
_model
.
onDidCancel
(
e
=>
{
if
(
this
.
_widget
&&
!
e
.
retrigger
)
{
this
.
_widget
.
getValue
().
hideWidget
();
}
}));
this
.
_toDispose
.
push
(
this
.
_editor
.
onDidBlurEditorWidget
(()
=>
{
this
.
_toDispose
.
add
(
this
.
_editor
.
onDidBlurEditorWidget
(()
=>
{
if
(
!
this
.
_sticky
)
{
this
.
_model
.
cancel
();
this
.
_model
.
clear
();
...
...
@@ -145,7 +139,7 @@ export class SuggestController implements IEditorContribution {
const
{
acceptSuggestionOnEnter
}
=
this
.
_editor
.
getConfiguration
().
contribInfo
;
acceptSuggestionsOnEnter
.
set
(
acceptSuggestionOnEnter
===
'
on
'
||
acceptSuggestionOnEnter
===
'
smart
'
);
};
this
.
_toDispose
.
push
(
this
.
_editor
.
onDidChangeConfiguration
((
e
)
=>
updateFromConfig
()));
this
.
_toDispose
.
add
(
this
.
_editor
.
onDidChangeConfiguration
((
e
)
=>
updateFromConfig
()));
updateFromConfig
();
}
...
...
@@ -155,7 +149,7 @@ export class SuggestController implements IEditorContribution {
}
dispose
():
void
{
this
.
_toDispose
=
dispose
(
this
.
_toDispose
);
this
.
_toDispose
.
dispose
(
);
this
.
_widget
.
dispose
();
if
(
this
.
_model
)
{
this
.
_model
.
dispose
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录