mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-27 04:07:13 +01:00
Improve lifecycle/registering in term sticky scroll
This commit is contained in:
+4
-5
@@ -5,6 +5,7 @@
|
||||
|
||||
import type { Terminal as RawXtermTerminal } from '@xterm/xterm';
|
||||
import { IDimension } from 'vs/base/browser/dom';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { Disposable, MutableDisposable } from 'vs/base/common/lifecycle';
|
||||
import 'vs/css!./media/stickyScroll';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -40,12 +41,11 @@ class TerminalStickyScrollContribution extends Disposable implements ITerminalCo
|
||||
) {
|
||||
super();
|
||||
|
||||
this._refreshState();
|
||||
this._configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration(TerminalSettingId.EnableStickyScroll)) {
|
||||
this._register(Event.runAndSubscribe(this._configurationService.onDidChangeConfiguration, e => {
|
||||
if (!e || e.affectsConfiguration(TerminalSettingId.EnableStickyScroll)) {
|
||||
this._refreshState();
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
xtermReady(xterm: IXtermTerminal & { raw: RawXtermTerminal }): void {
|
||||
@@ -87,7 +87,6 @@ class TerminalStickyScrollContribution extends Disposable implements ITerminalCo
|
||||
|
||||
private _tryEnable(): void {
|
||||
if (this._shouldBeEnabled()) {
|
||||
// TODO: Ensure open has happened to prevent race condition where not attached
|
||||
this._overlay.value = this._instantiationService.createInstance(TerminalStickyScrollOverlay, this._xterm!, this._instance.capabilities.get(TerminalCapability.CommandDetection)!);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -40,7 +40,7 @@ export class TerminalStickyScrollOverlay extends Disposable {
|
||||
private _stickyScrollOverlay?: RawXtermTerminal;
|
||||
private _serializeAddon?: SerializeAddonType;
|
||||
|
||||
private _canvasAddon = new MutableDisposable<CanvasAddonType>();
|
||||
private _canvasAddon = this._register(new MutableDisposable<CanvasAddonType>());
|
||||
private _pendingCanvasAddon?: CancelablePromise<void>;
|
||||
|
||||
private _element?: HTMLElement;
|
||||
@@ -77,15 +77,15 @@ export class TerminalStickyScrollOverlay extends Disposable {
|
||||
|
||||
// Eagerly create the overlay
|
||||
TerminalInstance.getXtermConstructor(this._keybindingService, this._contextKeyService).then(ctor => {
|
||||
this._stickyScrollOverlay = new ctor({
|
||||
this._stickyScrollOverlay = this._register(new ctor({
|
||||
rows: 1,
|
||||
cols: this._xterm.raw.cols,
|
||||
allowProposedApi: true,
|
||||
...this._getOptions()
|
||||
});
|
||||
}));
|
||||
|
||||
this._getSerializeAddonConstructor().then(SerializeAddon => {
|
||||
this._serializeAddon = new SerializeAddon();
|
||||
this._serializeAddon = this._register(new SerializeAddon());
|
||||
this._xterm.raw.loadAddon(this._serializeAddon);
|
||||
// Trigger a render as the serialize addon is required to render
|
||||
this._refresh();
|
||||
|
||||
Reference in New Issue
Block a user