From c6e4627b45bf426cfcbbca9116d7133eee3041d3 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 27 May 2026 18:18:24 +0000 Subject: [PATCH] Hoist _getCurrentLinkId() in print() loop Avoid calling _getCurrentLinkId() twice per codepoint when a hyperlink is active by reading the link id once before the print loop. Fixes #5940 Co-authored-by: Daniel Imms --- src/common/InputHandler.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/InputHandler.ts b/src/common/InputHandler.ts index 33e954811..ef07aa05e 100644 --- a/src/common/InputHandler.ts +++ b/src/common/InputHandler.ts @@ -531,6 +531,8 @@ export class InputHandler extends Disposable implements IInputHandler { return; } + const linkId = this._getCurrentLinkId(); + this._dirtyRowTracker.markDirty(this._activeBuffer.y); // handle wide chars: reset start_cell-1 if we would overwrite the second cell of a wide char @@ -567,8 +569,8 @@ export class InputHandler extends Disposable implements IInputHandler { if (screenReaderMode) { this._onA11yChar.fire(stringFromCodePoint(code)); } - if (this._getCurrentLinkId()) { - this._oscLinkService.addLineToLink(this._getCurrentLinkId(), this._activeBuffer.ybase + this._activeBuffer.y); + if (linkId) { + this._oscLinkService.addLineToLink(linkId, this._activeBuffer.ybase + this._activeBuffer.y); } // goto next line if ch would overflow