Skip to content

Add interactive shell keyboard shortcuts#57

Merged
mkrueger merged 4 commits intomainfrom
dev/mkrueger/shortcuts
May 4, 2026
Merged

Add interactive shell keyboard shortcuts#57
mkrueger merged 4 commits intomainfrom
dev/mkrueger/shortcuts

Conversation

@mkrueger
Copy link
Copy Markdown
Contributor

Summary:

  • Add readline-style interactive shell shortcuts for cursor movement, line deletion, Ctrl+D exit/delete, and history navigation.
  • Add inline reverse/forward incremental history search with highlighted, syntax-colored, truncated command previews.
  • Document interactive keyboard shortcuts and localize history-search prompt labels.

Validation:

  • dotnet test CosmosDBShell.Tests/CosmosDBShell.Tests.csproj --filter "FullyQualifiedNameHotkeyCommandTests|FullyQualifiedNameHighlighterTests|FullyQualifiedName~LocalizationKeyAuditTests" -nologo -p:BaseOutputPath=c:\work\CosmosDBShell\obj\agent-hotkey-test\
  • dotnet build CosmosDBShell/CosmosDBShell.csproj -nologo -v:m -p:BaseOutputPath=c:\work\CosmosDBShell\obj\agent-hotkey-build\

Related: AzureCosmosDB/cosmosdb-shell-preview#22

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds readline-style interactive editing and history-search features to the Cosmos DB Shell’s RadLine-based prompt, with corresponding docs, localization keys, and unit tests.

Changes:

  • Add new RadLine keybinding commands for cursor movement, line/word deletion, history navigation, and Ctrl+D exit/delete.
  • Implement reverse/forward incremental history search with syntax-highlighted, underlined match previews and truncation to console width.
  • Document keyboard shortcuts and localize history-search prompt labels; add comprehensive hotkey/search unit tests.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/navigation.md Documents interactive prompt keyboard shortcuts, including incremental history search.
CosmosDBShell/lang/en.ftl Adds localized labels for reverse/forward history search prompt states.
CosmosDBShell/Azure.Data.Cosmos.Shell.KeyBindings/ReverseSearchHistoryCommand.cs Implements interactive incremental history search UI/loop at the prompt.
CosmosDBShell/Azure.Data.Cosmos.Shell.KeyBindings/ReverseHistorySearch.cs Provides history match finding plus markup formatting/highlighting/underlining and truncation logic.
CosmosDBShell/Azure.Data.Cosmos.Shell.KeyBindings/ReverseHistorySearchResult.cs Adds a small result type for search matches and navigation state.
CosmosDBShell/Azure.Data.Cosmos.Shell.KeyBindings/MoveToStartOfLineCommand.cs Adds Ctrl+A behavior (move to start).
CosmosDBShell/Azure.Data.Cosmos.Shell.KeyBindings/MoveToEndOfLineCommand.cs Adds Ctrl+E behavior (move to end).
CosmosDBShell/Azure.Data.Cosmos.Shell.KeyBindings/MoveCursorLeftCommand.cs Adds Ctrl+B behavior (move left).
CosmosDBShell/Azure.Data.Cosmos.Shell.KeyBindings/MoveCursorRightCommand.cs Adds Ctrl+F behavior (move right).
CosmosDBShell/Azure.Data.Cosmos.Shell.KeyBindings/ExitShellCommand.cs Adds Ctrl+D behavior (exit on empty prompt, else delete char under cursor).
CosmosDBShell/Azure.Data.Cosmos.Shell.KeyBindings/DeleteToStartOfLineCommand.cs Adds Ctrl+U behavior (delete to start).
CosmosDBShell/Azure.Data.Cosmos.Shell.KeyBindings/DeleteToEndOfLineCommand.cs Adds Ctrl+K behavior (delete to end).
CosmosDBShell/Azure.Data.Cosmos.Shell.KeyBindings/DeletePreviousWordCommand.cs Adds Ctrl+W behavior (delete previous word).
CosmosDBShell/Azure.Data.Cosmos.Shell.KeyBindings/ClearScreenCommand.cs Moves command into KeyBindings namespace to align with usage.
CosmosDBShell/Azure.Data.Cosmos.Shell.KeyBindings/ClearCurrentLineCommand.cs Moves command into KeyBindings namespace to align with usage.
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ShellInterpreter.cs Wires new keybindings into the interactive line editor and exposes read-only history for search.
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ShellInterpreter.Highlighter.cs Refactors highlighter to expose markup-building API for reuse in history search preview rendering.
CosmosDBShell.Tests/Shell/HotkeyCommandTests.cs Adds unit tests for new keybinding behaviors and history search formatting/highlighting/truncation.

Comment thread CosmosDBShell/Azure.Data.Cosmos.Shell.KeyBindings/ReverseSearchHistoryCommand.cs Outdated
@mkrueger mkrueger requested a review from sevoku May 4, 2026 08:22
@mkrueger mkrueger enabled auto-merge May 4, 2026 09:18
Copilot AI review requested due to automatic review settings May 4, 2026 11:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

ShellInterpreter.Highlighter: BuildHighlightedMarkup now sets oldHighlightedText alongside oldHighlightStatement on the successful-parse path so the StartsWith reuse branch is actually reachable. ClearHighlightStatement also resets oldHighlightedText so the cached previous-statement reuse cannot outlive its text.

ReverseHistorySearch: FormatSearchPromptMarkup now also truncates the rendered query in the prefix when needed via TruncateQueryForPrompt, keeping the entire prompt within maxWidth even for long pasted queries. Prevents the prompt from wrapping and ReverseSearchHistoryCommand.ClearLine leaving artifacts. Added regression test ReverseSearch_FormatSearchPromptMarkup_TruncatesLongQueryToFitMaxWidth.
@mkrueger mkrueger merged commit 3429ab5 into main May 4, 2026
8 checks passed
@mkrueger mkrueger deleted the dev/mkrueger/shortcuts branch May 4, 2026 13:43
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.

3 participants