diff --git a/src/common/services/CoreService.test.ts b/src/common/services/CoreService.test.ts index 44018494..7ae8bf18 100644 --- a/src/common/services/CoreService.test.ts +++ b/src/common/services/CoreService.test.ts @@ -18,6 +18,19 @@ describe('CoreService', () => { new MockOptionsService()); }); + describe('isCursorInitialized', () => { + it('should be false by default', () => { + assert.equal(coreService.isCursorInitialized, false); + }); + it('should be true when showCursorImmediately is true', () => { + const coreServiceWithOption = new CoreService( + new MockBufferService(80, 30), + new MockLogService(), + new MockOptionsService({ showCursorImmediately: true })); + assert.equal(coreServiceWithOption.isCursorInitialized, true); + }); + }); + describe('reset', () => { it('should not affect isCursorInitialized', () => { coreService.isCursorInitialized = true; diff --git a/src/common/services/CoreService.ts b/src/common/services/CoreService.ts index 7e1ef64b..9981ba21 100644 --- a/src/common/services/CoreService.ts +++ b/src/common/services/CoreService.ts @@ -38,7 +38,7 @@ const DEFAULT_KITTY_KEYBOARD_STATE = (): IKittyKeyboardState => ({ export class CoreService extends Disposable implements ICoreService { public serviceBrand: any; - public isCursorInitialized: boolean = false; + public isCursorInitialized: boolean; public isCursorHidden: boolean = false; public modes: IModes; public decPrivateModes: IDecPrivateModes; @@ -59,6 +59,7 @@ export class CoreService extends Disposable implements ICoreService { @IOptionsService private readonly _optionsService: IOptionsService ) { super(); + this.isCursorInitialized = _optionsService.rawOptions.showCursorImmediately ?? false; this.modes = clone(DEFAULT_MODES); this.decPrivateModes = clone(DEFAULT_DEC_PRIVATE_MODES); this.kittyKeyboard = DEFAULT_KITTY_KEYBOARD_STATE(); diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index f08f61f8..4ae8bf96 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -12,6 +12,7 @@ import { Emitter } from 'vs/base/common/event'; export const DEFAULT_OPTIONS: Readonly> = { cols: 80, rows: 24, + showCursorImmediately: false, cursorBlink: false, cursorStyle: 'block', cursorWidth: 1, diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index d9698899..bbf36771 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -253,6 +253,7 @@ export interface ITerminalOptions { rescaleOverlappingGlyphs?: boolean; rightClickSelectsWord?: boolean; rows?: number; + showCursorImmediately?: boolean; screenReaderMode?: boolean; scrollback?: number; scrollOnUserInput?: boolean; diff --git a/typings/xterm-headless.d.ts b/typings/xterm-headless.d.ts index ef7a0af5..c12d6ba9 100644 --- a/typings/xterm-headless.d.ts +++ b/typings/xterm-headless.d.ts @@ -252,6 +252,13 @@ declare module '@xterm/headless' { * The number of rows in the terminal. */ rows?: number; + + /** + * Whether to show the cursor immediately when the terminal is created. + * When false (default), the cursor will not be visible until the terminal + * is focused for the first time. + */ + showCursorImmediately?: boolean; } /** diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index f2cd3c23..ee3364dd 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -340,6 +340,13 @@ declare module '@xterm/xterm' { * The number of rows in the terminal. */ rows?: number; + + /** + * Whether to show the cursor immediately when the terminal is created. + * When false (default), the cursor will not be visible until the terminal + * is focused for the first time. + */ + showCursorImmediately?: boolean; } /**