[PR #144] [MERGED] Fix undefined cursorPosition getter in InputRenderable class #321

Closed
opened 2026-03-02 23:45:57 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/144
Author: @Copilot
Created: 9/7/2025
Status: Merged
Merged: 9/7/2025
Merged by: @thdxr

Base: mainHead: copilot/fix-143


📝 Commits (3)

  • 2990c27 Initial plan
  • 252fc77 Add missing cursorPosition getter to InputRenderable class
  • eea77f3 Remove Input.test.ts file as requested

📊 Changes

1 file changed (+4 additions, -0 deletions)

View changed files

📝 packages/core/src/renderables/Input.ts (+4 -0)

📄 Description

The InputRenderable class was missing a getter for the cursorPosition property, causing reading input.cursorPosition to return undefined while setting worked correctly.

Problem

const input = new InputRenderable(ctx, {});
input.cursorPosition = 5;  // ✅ Works - setter exists
console.log(input.cursorPosition);  // ❌ Returns undefined - no getter

Root Cause

The class had a public setter but no corresponding getter:

// Before - only setter existed
public set cursorPosition(position: number) {
  const newPosition = Math.max(0, Math.min(position, this._value.length))
  if (this._cursorPosition !== newPosition) {
    this._cursorPosition = newPosition
    this.requestRender()
    this.updateCursorPosition()
  }
}

Solution

Added the missing getter that returns the private _cursorPosition field:

public get cursorPosition(): number {
  return this._cursorPosition
}

This follows the same pattern as the existing value getter in the same class and maintains consistency with the codebase.

Fixes #143.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/144 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 9/7/2025 **Status:** ✅ Merged **Merged:** 9/7/2025 **Merged by:** [@thdxr](https://github.com/thdxr) **Base:** `main` ← **Head:** `copilot/fix-143` --- ### 📝 Commits (3) - [`2990c27`](https://github.com/anomalyco/opentui/commit/2990c279d4f9c61b250c71945683c3d65cd655e0) Initial plan - [`252fc77`](https://github.com/anomalyco/opentui/commit/252fc77daf662b76b3e06b12324049bbfdb8d47d) Add missing cursorPosition getter to InputRenderable class - [`eea77f3`](https://github.com/anomalyco/opentui/commit/eea77f3a0c103877a0d34ca696d4dc6d421999eb) Remove Input.test.ts file as requested ### 📊 Changes **1 file changed** (+4 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/renderables/Input.ts` (+4 -0) </details> ### 📄 Description The `InputRenderable` class was missing a getter for the `cursorPosition` property, causing reading `input.cursorPosition` to return `undefined` while setting worked correctly. ## Problem ```typescript const input = new InputRenderable(ctx, {}); input.cursorPosition = 5; // ✅ Works - setter exists console.log(input.cursorPosition); // ❌ Returns undefined - no getter ``` ## Root Cause The class had a public setter but no corresponding getter: ```typescript // Before - only setter existed public set cursorPosition(position: number) { const newPosition = Math.max(0, Math.min(position, this._value.length)) if (this._cursorPosition !== newPosition) { this._cursorPosition = newPosition this.requestRender() this.updateCursorPosition() } } ``` ## Solution Added the missing getter that returns the private `_cursorPosition` field: ```typescript public get cursorPosition(): number { return this._cursorPosition } ``` This follows the same pattern as the existing `value` getter in the same class and maintains consistency with the codebase. Fixes #143. <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 23:45:57 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#321
No description provided.