Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ad7cbfda
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,发现更多精彩内容 >>
提交
ad7cbfda
编写于
7月 19, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use toDisposable in more places in editor
上级
f1e05055
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
71 addition
and
89 deletion
+71
-89
src/vs/editor/common/modes/languageConfigurationRegistry.ts
src/vs/editor/common/modes/languageConfigurationRegistry.ts
+6
-8
src/vs/editor/common/modes/languageFeatureRegistry.ts
src/vs/editor/common/modes/languageFeatureRegistry.ts
+10
-12
src/vs/editor/common/modes/tokenizationRegistry.ts
src/vs/editor/common/modes/tokenizationRegistry.ts
+7
-9
src/vs/editor/common/services/editorWorkerServiceImpl.ts
src/vs/editor/common/services/editorWorkerServiceImpl.ts
+4
-6
src/vs/editor/common/view/viewEvents.ts
src/vs/editor/common/view/viewEvents.ts
+8
-10
src/vs/editor/contrib/codelens/codelensController.ts
src/vs/editor/contrib/codelens/codelensController.ts
+20
-22
src/vs/editor/standalone/browser/simpleServices.ts
src/vs/editor/standalone/browser/simpleServices.ts
+12
-16
src/vs/editor/standalone/browser/standaloneCodeEditor.ts
src/vs/editor/standalone/browser/standaloneCodeEditor.ts
+4
-6
未找到文件。
src/vs/editor/common/modes/languageConfigurationRegistry.ts
浏览文件 @
ad7cbfda
...
...
@@ -13,7 +13,7 @@ import { Event, Emitter } from 'vs/base/common/event';
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
DEFAULT_WORD_REGEXP
,
ensureValidWordDefinition
}
from
'
vs/editor/common/model/wordHelper
'
;
import
{
createScopedLineTokens
}
from
'
vs/editor/common/modes/supports
'
;
import
{
LineTokens
}
from
'
vs/editor/common/core/lineTokens
'
;
...
...
@@ -189,14 +189,12 @@ export class LanguageConfigurationRegistryImpl {
let
current
=
new
RichEditSupport
(
languageIdentifier
,
previous
,
configuration
);
this
.
_entries
[
languageIdentifier
.
id
]
=
current
;
this
.
_onDidChange
.
fire
({
languageIdentifier
});
return
{
dispose
:
()
=>
{
if
(
this
.
_entries
[
languageIdentifier
.
id
]
===
current
)
{
this
.
_entries
[
languageIdentifier
.
id
]
=
previous
;
this
.
_onDidChange
.
fire
({
languageIdentifier
});
}
return
toDisposable
(()
=>
{
if
(
this
.
_entries
[
languageIdentifier
.
id
]
===
current
)
{
this
.
_entries
[
languageIdentifier
.
id
]
=
previous
;
this
.
_onDidChange
.
fire
({
languageIdentifier
});
}
};
}
)
;
}
private
_getRichEditSupport
(
languageId
:
LanguageId
):
RichEditSupport
{
...
...
src/vs/editor/common/modes/languageFeatureRegistry.ts
浏览文件 @
ad7cbfda
...
...
@@ -6,7 +6,7 @@
'
use strict
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
LanguageSelector
,
score
}
from
'
vs/editor/common/modes/languageSelector
'
;
import
{
shouldSynchronizeModel
}
from
'
vs/editor/common/services/modelService
'
;
...
...
@@ -54,19 +54,17 @@ export default class LanguageFeatureRegistry<T> {
this
.
_lastCandidate
=
undefined
;
this
.
_onDidChange
.
fire
(
this
.
_entries
.
length
);
return
{
dispose
:
()
=>
{
if
(
entry
)
{
let
idx
=
this
.
_entries
.
indexOf
(
entry
);
if
(
idx
>=
0
)
{
this
.
_entries
.
splice
(
idx
,
1
);
this
.
_lastCandidate
=
undefined
;
this
.
_onDidChange
.
fire
(
this
.
_entries
.
length
);
entry
=
undefined
;
}
return
toDisposable
(()
=>
{
if
(
entry
)
{
let
idx
=
this
.
_entries
.
indexOf
(
entry
);
if
(
idx
>=
0
)
{
this
.
_entries
.
splice
(
idx
,
1
);
this
.
_lastCandidate
=
undefined
;
this
.
_onDidChange
.
fire
(
this
.
_entries
.
length
);
entry
=
undefined
;
}
}
};
}
)
;
}
has
(
model
:
ITextModel
):
boolean
{
...
...
src/vs/editor/common/modes/tokenizationRegistry.ts
浏览文件 @
ad7cbfda
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
ColorId
,
ITokenizationRegistry
,
ITokenizationSupport
,
ITokenizationSupportChangedEvent
}
from
'
vs/editor/common/modes
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
...
...
@@ -33,15 +33,13 @@ export class TokenizationRegistryImpl implements ITokenizationRegistry {
public
register
(
language
:
string
,
support
:
ITokenizationSupport
):
IDisposable
{
this
.
_map
[
language
]
=
support
;
this
.
fire
([
language
]);
return
{
dispose
:
()
=>
{
if
(
this
.
_map
[
language
]
!==
support
)
{
return
;
}
delete
this
.
_map
[
language
];
this
.
fire
([
language
]);
return
toDisposable
(()
=>
{
if
(
this
.
_map
[
language
]
!==
support
)
{
return
;
}
};
delete
this
.
_map
[
language
];
this
.
fire
([
language
]);
});
}
public
get
(
language
:
string
):
ITokenizationSupport
{
...
...
src/vs/editor/common/services/editorWorkerServiceImpl.ts
浏览文件 @
ad7cbfda
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
IntervalTimer
,
ShallowCancelThenPromise
,
wireCancellationToken
}
from
'
vs/base/common/async
'
;
import
{
Disposable
,
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
,
IDisposable
,
dispose
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
SimpleWorkerClient
,
logOnceWebWorkerWarning
}
from
'
vs/base/common/worker/simpleWorker
'
;
...
...
@@ -285,11 +285,9 @@ class EditorModelManager extends Disposable {
toDispose
.
push
(
model
.
onWillDispose
(()
=>
{
this
.
_stopModelSync
(
modelUrl
);
}));
toDispose
.
push
({
dispose
:
()
=>
{
this
.
_proxy
.
acceptRemovedModel
(
modelUrl
);
}
});
toDispose
.
push
(
toDisposable
(()
=>
{
this
.
_proxy
.
acceptRemovedModel
(
modelUrl
);
}));
this
.
_syncedModels
[
modelUrl
]
=
toDispose
;
}
...
...
src/vs/editor/common/view/viewEvents.ts
浏览文件 @
ad7cbfda
...
...
@@ -9,7 +9,7 @@ import { Selection } from 'vs/editor/common/core/selection';
import
{
ScrollEvent
}
from
'
vs/base/common/scrollable
'
;
import
{
IConfigurationChangedEvent
}
from
'
vs/editor/common/config/editorOptions
'
;
import
*
as
errors
from
'
vs/base/common/errors
'
;
import
{
IDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
Disposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ScrollType
}
from
'
vs/editor/common/editorCommon
'
;
export
const
enum
ViewEventType
{
...
...
@@ -354,17 +354,15 @@ export class ViewEventEmitter extends Disposable {
public
addEventListener
(
listener
:
(
events
:
ViewEvent
[])
=>
void
):
IDisposable
{
this
.
_listeners
.
push
(
listener
);
return
{
dispose
:
()
=>
{
let
listeners
=
this
.
_listeners
;
for
(
let
i
=
0
,
len
=
listeners
.
length
;
i
<
len
;
i
++
)
{
if
(
listeners
[
i
]
===
listener
)
{
listeners
.
splice
(
i
,
1
);
break
;
}
return
toDisposable
(()
=>
{
let
listeners
=
this
.
_listeners
;
for
(
let
i
=
0
,
len
=
listeners
.
length
;
i
<
len
;
i
++
)
{
if
(
listeners
[
i
]
===
listener
)
{
listeners
.
splice
(
i
,
1
);
break
;
}
}
};
}
)
;
}
}
...
...
src/vs/editor/contrib/codelens/codelensController.ts
浏览文件 @
ad7cbfda
...
...
@@ -5,20 +5,20 @@
'
use strict
'
;
import
{
RunOnceScheduler
,
CancelablePromise
,
createCancelablePromise
}
from
'
vs/base/common/async
'
;
import
{
CancelablePromise
,
createCancelablePromise
,
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
CodeLensProviderRegistry
,
ICodeLensSymbol
}
from
'
vs/editor/common/modes
'
;
import
{
dispose
,
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
StableEditorScrollState
}
from
'
vs/editor/browser/core/editorState
'
;
import
*
as
editorBrowser
from
'
vs/editor/browser/editorBrowser
'
;
import
{
registerEditorContribution
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
ICodeLensData
,
getCodeLensData
}
from
'
./codelens
'
;
import
{
IConfigurationChangedEvent
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
CodeLens
,
CodeLensHelper
}
from
'
vs/editor/contrib/codelens/codelensWidget
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
IModelDecorationsChangeAccessor
}
from
'
vs/editor/common/model
'
;
import
{
CodeLensProviderRegistry
,
ICodeLensSymbol
}
from
'
vs/editor/common/modes
'
;
import
{
CodeLens
,
CodeLensHelper
}
from
'
vs/editor/contrib/codelens/codelensWidget
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
StableEditorScrollState
}
from
'
vs/editor/browser/core/editorState
'
;
import
{
getCodeLensData
,
ICodeLensData
}
from
'
./codelens
'
;
export
class
CodeLensContribution
implements
editorCommon
.
IEditorContribution
{
...
...
@@ -167,22 +167,20 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
this
.
_localToDispose
.
push
(
this
.
_editor
.
onDidLayoutChange
(
e
=>
{
this
.
_detectVisibleLenses
.
schedule
();
}));
this
.
_localToDispose
.
push
({
dispose
:
()
=>
{
if
(
this
.
_editor
.
getModel
())
{
const
scrollState
=
StableEditorScrollState
.
capture
(
this
.
_editor
);
this
.
_editor
.
changeDecorations
((
changeAccessor
)
=>
{
this
.
_editor
.
changeViewZones
((
accessor
)
=>
{
this
.
_disposeAllLenses
(
changeAccessor
,
accessor
);
});
this
.
_localToDispose
.
push
(
toDisposable
(()
=>
{
if
(
this
.
_editor
.
getModel
())
{
const
scrollState
=
StableEditorScrollState
.
capture
(
this
.
_editor
);
this
.
_editor
.
changeDecorations
((
changeAccessor
)
=>
{
this
.
_editor
.
changeViewZones
((
accessor
)
=>
{
this
.
_disposeAllLenses
(
changeAccessor
,
accessor
);
});
scrollState
.
restore
(
this
.
_editor
);
}
else
{
// No accessors available
this
.
_disposeAllLenses
(
null
,
null
);
}
}
);
scrollState
.
restore
(
this
.
_editor
);
}
else
{
// No accessors available
this
.
_disposeAllLenses
(
null
,
null
);
}
});
})
)
;
scheduler
.
schedule
();
}
...
...
src/vs/editor/standalone/browser/simpleServices.ts
浏览文件 @
ad7cbfda
...
...
@@ -24,7 +24,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import
{
IProgressService
,
IProgressRunner
}
from
'
vs/platform/progress/common/progress
'
;
import
{
ITextResourceConfigurationService
}
from
'
vs/editor/common/services/resourceConfiguration
'
;
import
{
ITextModelService
,
ITextModelContentProvider
,
ITextEditorModel
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
IDisposable
,
IReference
,
ImmortalReference
,
combinedDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
IReference
,
ImmortalReference
,
combinedDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
KeybindingsRegistry
,
IKeybindingItem
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
...
...
@@ -230,11 +230,9 @@ export class StandaloneCommandService implements ICommandService {
public
addCommand
(
command
:
ICommand
):
IDisposable
{
const
{
id
}
=
command
;
this
.
_dynamicCommands
[
id
]
=
command
;
return
{
dispose
:
()
=>
{
delete
this
.
_dynamicCommands
[
id
];
}
};
return
toDisposable
(()
=>
{
delete
this
.
_dynamicCommands
[
id
];
});
}
public
executeCommand
<
T
>
(
id
:
string
,
...
args
:
any
[]):
TPromise
<
T
>
{
...
...
@@ -289,18 +287,16 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
weight2
:
0
});
toDispose
.
push
({
dispose
:
()
=>
{
for
(
let
i
=
0
;
i
<
this
.
_dynamicKeybindings
.
length
;
i
++
)
{
let
kb
=
this
.
_dynamicKeybindings
[
i
];
if
(
kb
.
command
===
commandId
)
{
this
.
_dynamicKeybindings
.
splice
(
i
,
1
);
this
.
updateResolver
({
source
:
KeybindingSource
.
Default
});
return
;
}
toDispose
.
push
(
toDisposable
(()
=>
{
for
(
let
i
=
0
;
i
<
this
.
_dynamicKeybindings
.
length
;
i
++
)
{
let
kb
=
this
.
_dynamicKeybindings
[
i
];
if
(
kb
.
command
===
commandId
)
{
this
.
_dynamicKeybindings
.
splice
(
i
,
1
);
this
.
updateResolver
({
source
:
KeybindingSource
.
Default
});
return
;
}
}
});
})
)
;
let
commandService
=
this
.
_commandService
;
if
(
commandService
instanceof
StandaloneCommandService
)
{
...
...
src/vs/editor/standalone/browser/standaloneCodeEditor.ts
浏览文件 @
ad7cbfda
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
Disposable
,
IDisposable
,
combinedDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
,
IDisposable
,
combinedDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IContextViewService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -272,11 +272,9 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
// Store it under the original id, such that trigger with the original id will work
this
.
_actions
[
id
]
=
internalAction
;
toDispose
.
push
({
dispose
:
()
=>
{
delete
this
.
_actions
[
id
];
}
});
toDispose
.
push
(
toDisposable
(()
=>
{
delete
this
.
_actions
[
id
];
}));
return
combinedDisposable
(
toDispose
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录