|
5 | 5 |
|
6 | 6 | 'use strict'; |
7 | 7 |
|
8 | | -import { RunOnceScheduler, CancelablePromise, createCancelablePromise } from 'vs/base/common/async'; |
| 8 | +import { CancelablePromise, createCancelablePromise, RunOnceScheduler } from 'vs/base/common/async'; |
9 | 9 | import { onUnexpectedError } from 'vs/base/common/errors'; |
10 | | -import { IDisposable, dispose } from 'vs/base/common/lifecycle'; |
11 | | -import { ICommandService } from 'vs/platform/commands/common/commands'; |
12 | | -import * as editorCommon from 'vs/editor/common/editorCommon'; |
13 | | -import { CodeLensProviderRegistry, ICodeLensSymbol } from 'vs/editor/common/modes'; |
| 10 | +import { dispose, IDisposable, toDisposable } from 'vs/base/common/lifecycle'; |
| 11 | +import { StableEditorScrollState } from 'vs/editor/browser/core/editorState'; |
14 | 12 | import * as editorBrowser from 'vs/editor/browser/editorBrowser'; |
15 | 13 | import { registerEditorContribution } from 'vs/editor/browser/editorExtensions'; |
16 | | -import { ICodeLensData, getCodeLensData } from './codelens'; |
17 | 14 | import { IConfigurationChangedEvent } from 'vs/editor/common/config/editorOptions'; |
18 | | -import { CodeLens, CodeLensHelper } from 'vs/editor/contrib/codelens/codelensWidget'; |
| 15 | +import * as editorCommon from 'vs/editor/common/editorCommon'; |
19 | 16 | import { IModelDecorationsChangeAccessor } from 'vs/editor/common/model'; |
| 17 | +import { CodeLensProviderRegistry, ICodeLensSymbol } from 'vs/editor/common/modes'; |
| 18 | +import { CodeLens, CodeLensHelper } from 'vs/editor/contrib/codelens/codelensWidget'; |
| 19 | +import { ICommandService } from 'vs/platform/commands/common/commands'; |
20 | 20 | import { INotificationService } from 'vs/platform/notification/common/notification'; |
21 | | -import { StableEditorScrollState } from 'vs/editor/browser/core/editorState'; |
| 21 | +import { getCodeLensData, ICodeLensData } from './codelens'; |
22 | 22 |
|
23 | 23 | export class CodeLensContribution implements editorCommon.IEditorContribution { |
24 | 24 |
|
@@ -167,22 +167,20 @@ export class CodeLensContribution implements editorCommon.IEditorContribution { |
167 | 167 | this._localToDispose.push(this._editor.onDidLayoutChange(e => { |
168 | 168 | this._detectVisibleLenses.schedule(); |
169 | 169 | })); |
170 | | - this._localToDispose.push({ |
171 | | - dispose: () => { |
172 | | - if (this._editor.getModel()) { |
173 | | - const scrollState = StableEditorScrollState.capture(this._editor); |
174 | | - this._editor.changeDecorations((changeAccessor) => { |
175 | | - this._editor.changeViewZones((accessor) => { |
176 | | - this._disposeAllLenses(changeAccessor, accessor); |
177 | | - }); |
| 170 | + this._localToDispose.push(toDisposable(() => { |
| 171 | + if (this._editor.getModel()) { |
| 172 | + const scrollState = StableEditorScrollState.capture(this._editor); |
| 173 | + this._editor.changeDecorations((changeAccessor) => { |
| 174 | + this._editor.changeViewZones((accessor) => { |
| 175 | + this._disposeAllLenses(changeAccessor, accessor); |
178 | 176 | }); |
179 | | - scrollState.restore(this._editor); |
180 | | - } else { |
181 | | - // No accessors available |
182 | | - this._disposeAllLenses(null, null); |
183 | | - } |
| 177 | + }); |
| 178 | + scrollState.restore(this._editor); |
| 179 | + } else { |
| 180 | + // No accessors available |
| 181 | + this._disposeAllLenses(null, null); |
184 | 182 | } |
185 | | - }); |
| 183 | + })); |
186 | 184 |
|
187 | 185 | scheduler.schedule(); |
188 | 186 | } |
|
0 commit comments