Skip to content

Fix #341: Switch chat input history only from the first or last visual line - #514

Open
Lars Vogel (vogella) wants to merge 1 commit into
microsoft:mainfrom
vogellacompany:chat-input-arrow-keys-history
Open

Lars Vogel (vogella) wants to merge 1 commit into
microsoft:mainfrom
vogellacompany:chat-input-arrow-keys-history

Conversation

@vogella

@vogella Lars Vogel (vogella) commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Pressing the up or down arrow in a multi-line chat prompt could replace the whole prompt with an older one instead of moving the caret. The input guessed whether the caret had moved by comparing logical line numbers, which stay the same within a word-wrapped line and go stale after a mouse click. It now checks, before StyledText handles the key, whether the caret is on the first or last visual line, and switches the input history only from there, so arrow keys behave like in any other text field while history stays one key press away. This also removes the line tracking state, and new tests cover wrapped-line navigation and history switching; the test fixture now stubs the chat font service and rethrows failures from the display thread, so its tests actually run. Fixes #341.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test fixture leaves getChatFontService() unstubbed, causing a NullPointerException during viewer setup before any of the four new regression tests reaches its assertions.

1 open issue
What changed in this PR

This PR addresses #341 by preserving normal arrow-key navigation in the Eclipse chat input and switching history only when the caret cannot move.

Changes:

  • Compare caret offsets before and after key handling instead of tracking logical line numbers.
  • Remove obsolete line-tracking state and reset logic.
  • Add regression tests for wrapped-line navigation and history switching.
File Description
com.microsoft.copilot.eclipse.ui/​src/​com/​microsoft/​copilot/​eclipse/​ui/​chat/​ChatInputTextViewer.java Uses caret movement to distinguish text navigation from history switching.
com.microsoft.copilot.eclipse.ui.test/​src/​com/​microsoft/​copilot/​eclipse/​ui/​chat/​ChatInputTextViewerTests.java Adds service mocks and four arrow-key regression tests.

Review effort: Balanced

Comment on lines +52 to +53
lenient().when(mockChatServiceManager.getUserPreferenceService()).thenReturn(mockUserPreferenceService);
lenient().when(mockChatServiceManager.getChatCompletionService()).thenReturn(mockChatCompletionService);
…ast visual line

The chat input guessed from the logical line number whether an arrow key moved the caret, so moving within a wrapped line, or from a line reached by mouse, replaced the prompt with an older one. It now checks before the key is handled whether the caret is on the first or last visual line and only then switches the history.

Assisted-by: multiple AI agents and layers of automated tooling 🤖
@vogella
Lars Vogel (vogella) force-pushed the chat-input-arrow-keys-history branch from d8301eb to e4f9923 Compare November 6, 2026 01:13
@vogella Lars Vogel (vogella) changed the title Fix #341: Switch chat input history only when the caret cannot move Fix #341: Switch chat input history only from the first or last visual line Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] Eclipse Chat text edit field: add option disable input history accessible by hard-coded through arrow_up/arrow_down

2 participants