diff --git a/.eslintrc.json b/.eslintrc.json index 61d778150f1..7b8936e0703 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -856,7 +856,11 @@ }, // TODO@layers "tas-client-umd", // node module allowed even in /common/ "vscode-textmate", // node module allowed even in /common/ - "@vscode/vscode-languagedetection" // node module allowed even in /common/ + "@vscode/vscode-languagedetection", // node module allowed even in /common/ + { + "when": "hasBrowser", + "pattern": "@xterm/xterm" + } // node module allowed even in /browser/ ] }, { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index f7ca12e5ca7..a9bd15f2557 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -1858,10 +1858,6 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { this.xterm.raw.resize(cols, rows); TerminalInstance._lastKnownGridDimensions = { cols, rows }; - - if (this._isVisible) { - this.xterm.forceUnpause(); - } } if (immediate) { diff --git a/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts b/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts index 0b5f4991d29..23729e0c8d1 100644 --- a/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts +++ b/src/vs/workbench/contrib/terminal/browser/xterm-private.d.ts @@ -3,8 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -/* eslint-disable @typescript-eslint/naming-convention */ - import { IBufferCell } from '@xterm/xterm'; export type XtermAttributes = Omit & { clone?(): XtermAttributes }; @@ -14,17 +12,6 @@ export interface IXtermCore { readonly scrollBarWidth: number; _innerRefresh(): void; }; - _onData: IEventEmitter; - _onKey: IEventEmitter<{ key: string }>; - - _charSizeService: { - width: number; - height: number; - }; - - coreService: { - triggerDataEvent(data: string, wasUserInput?: boolean): void; - }; _inputHandler: { _curAttrData: XtermAttributes; @@ -42,10 +29,5 @@ export interface IXtermCore { _renderer: { value?: unknown; }; - _handleIntersectionChange: any; }; } - -export interface IEventEmitter { - fire(e: T): void; -} diff --git a/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts b/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts index 260f786845e..8907ac72e1d 100644 --- a/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts +++ b/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts @@ -437,19 +437,6 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach this._core.viewport?._innerRefresh(); } - forceUnpause() { - // HACK: Force the renderer to unpause by simulating an IntersectionObserver event. - // This is to fix an issue where dragging the windpow to the top of the screen to - // maximize on Windows/Linux would fire an event saying that the terminal was not - // visible. - if (!!this._canvasAddon) { - this._core._renderService?._handleIntersectionChange({ intersectionRatio: 1 }); - // HACK: Force a refresh of the screen to ensure links are refresh corrected. - // This can probably be removed when the above hack is fixed in Chromium. - this.raw.refresh(0, this.raw.rows - 1); - } - } - async findNext(term: string, searchOptions: ISearchOptions): Promise { this._updateFindColors(searchOptions); return (await this._getSearchAddon()).findNext(term, searchOptions); diff --git a/src/vs/workbench/contrib/terminal/test/browser/capabilities/partialCommandDetectionCapability.test.ts b/src/vs/workbench/contrib/terminal/test/browser/capabilities/partialCommandDetectionCapability.test.ts index e37020815fd..016da9ab599 100644 --- a/src/vs/workbench/contrib/terminal/test/browser/capabilities/partialCommandDetectionCapability.test.ts +++ b/src/vs/workbench/contrib/terminal/test/browser/capabilities/partialCommandDetectionCapability.test.ts @@ -3,20 +3,15 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { deepStrictEqual } from 'assert'; -import { PartialCommandDetectionCapability } from 'vs/platform/terminal/common/capabilities/partialCommandDetectionCapability'; import type { IMarker, Terminal } from '@xterm/xterm'; -import { IXtermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private'; +import { deepStrictEqual } from 'assert'; import { importAMDNodeModule } from 'vs/amdX'; -import { writeP } from 'vs/workbench/contrib/terminal/browser/terminalTestHelpers'; import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils'; - -interface TestTerminal extends Terminal { - _core: IXtermCore; -} +import { PartialCommandDetectionCapability } from 'vs/platform/terminal/common/capabilities/partialCommandDetectionCapability'; +import { writeP } from 'vs/workbench/contrib/terminal/browser/terminalTestHelpers'; suite('PartialCommandDetectionCapability', () => { - let xterm: TestTerminal; + let xterm: Terminal; let capability: PartialCommandDetectionCapability; let addEvents: IMarker[]; @@ -28,7 +23,7 @@ suite('PartialCommandDetectionCapability', () => { setup(async () => { const TerminalCtor = (await importAMDNodeModule('@xterm/xterm', 'lib/xterm.js')).Terminal; - xterm = new TerminalCtor({ allowProposedApi: true, cols: 80 }) as TestTerminal; + xterm = new TerminalCtor({ allowProposedApi: true, cols: 80 }) as Terminal; capability = new PartialCommandDetectionCapability(xterm); addEvents = []; capability.onCommandFinished(e => addEvents.push(e)); @@ -38,11 +33,11 @@ suite('PartialCommandDetectionCapability', () => { test('should not add commands when the cursor position is too close to the left side', async () => { assertCommands([]); - xterm._core._onData.fire('\x0d'); + xterm.input('\x0d'); await writeP(xterm, '\r\n'); assertCommands([]); await writeP(xterm, 'a'); - xterm._core._onData.fire('\x0d'); + xterm.input('\x0d'); await writeP(xterm, '\r\n'); assertCommands([]); }); @@ -50,11 +45,11 @@ suite('PartialCommandDetectionCapability', () => { test('should add commands when the cursor position is not too close to the left side', async () => { assertCommands([]); await writeP(xterm, 'ab'); - xterm._core._onData.fire('\x0d'); + xterm.input('\x0d'); await writeP(xterm, '\r\n\r\n'); assertCommands([0]); await writeP(xterm, 'cd'); - xterm._core._onData.fire('\x0d'); + xterm.input('\x0d'); await writeP(xterm, '\r\n'); assertCommands([0, 2]); }); diff --git a/src/vs/workbench/services/driver/browser/driver.ts b/src/vs/workbench/services/driver/browser/driver.ts index 7b63e054bb1..13ddd13f671 100644 --- a/src/vs/workbench/services/driver/browser/driver.ts +++ b/src/vs/workbench/services/driver/browser/driver.ts @@ -17,6 +17,7 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; import { IWindowDriver, IElement, ILocaleInfo, ILocalizedStrings } from 'vs/workbench/services/driver/common/driver'; import { ILifecycleService, LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'; +import type { Terminal as XtermTerminal } from '@xterm/xterm'; export class BrowserWindowDriver implements IWindowDriver { @@ -174,13 +175,13 @@ export class BrowserWindowDriver implements IWindowDriver { throw new Error(`Element not found: ${selector}`); } - const xterm = (element as any).xterm; + const xterm = (element as any).xterm as (XtermTerminal | undefined); if (!xterm) { throw new Error(`Xterm not found: ${selector}`); } - xterm._core.coreService.triggerDataEvent(text); + xterm.input(text); } getLocaleInfo(): Promise {