fix: use platform-specific arrow key sequences for Windows compatibility#2436
Closed
maxandersen wants to merge 1 commit intojbangdev:mainfrom
Closed
fix: use platform-specific arrow key sequences for Windows compatibility#2436maxandersen wants to merge 1 commit intojbangdev:mainfrom
maxandersen wants to merge 1 commit intojbangdev:mainfrom
Conversation
Fixes jbangdev#2403, jbangdev#2348 The `jbang deps search` command was broken on Windows terminals because it used hardcoded ANSI escape sequences (\033[A, \033[B, etc.) for arrow keys. These sequences don't work correctly on Windows CMD, PowerShell, or Git Bash. Changes: - ComboBox.java: Use KeyMap.key(terminal, Capability) to get platform- specific escape sequences for up/down arrow keys with fallback to standard ANSI sequences - ArtifactSearchWidget.java: Same fix for left/right arrow keys used in phase navigation This ensures cross-platform compatibility while maintaining backward compatibility for terminals that don't provide capability information. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Collaborator
Author
|
lets fix this using a different tui. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2403
Fixes #2348
Problem
The
jbang deps searchcommand was broken on Windows terminals (CMD, PowerShell, Git Bash). When pressing arrow keys:Root Cause
The code used hardcoded ANSI escape sequences for arrow keys:
\033[A\033[B\033[D\033[CThese sequences don't work correctly on Windows terminals because different terminals send different escape sequences.
Solution
Use JLine3's
KeyMap.key(terminal, Capability)method to get platform-specific escape sequences:KeyMap.key(terminal, Capability.key_up)KeyMap.key(terminal, Capability.key_down)KeyMap.key(terminal, Capability.key_left)KeyMap.key(terminal, Capability.key_right)This method queries the terminal's capabilities and returns the correct sequence for each platform, with fallback to standard ANSI sequences for terminals that don't provide capability information.
Changes
Testing
🤖 Generated with Claude Code