PSReadLine doesn't respect cursor position when using `cmd+k` or `cmd+l` on macOS

Open
#4,074 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp, macos, powershell
Domain
cli

Research direction

Reproduce the behavior using Set-PSReadLineKeyHandler, the null prompt, Clear-Host, and typing after moving the cursor to position 5,5 on macOS. Start by tracing the cursor-position handling between the key handler and subsequent input; done means typed text remains at position 5,5 instead of returning to 1,1.

Written by the indexing model from the issue text.

Description

Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.
Exception report
N/A
Screenshot

https://github.com/user-attachments/assets/7b4612e4-e6ae-4fb5-b24d-b9aeefcdd429

Environment data
PS Version: 7.4.2
PS HostName: ConsoleHost
PSReadLine Version: 2.3.5
PSReadLine EditMode: Emacs
OS: Darwin Dans-MacBook-Pro.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:14:38 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6020 arm64
BufferWidth: 80
BufferHeight: 24
Steps to reproduce
  1. Set the following key handler
Set-PSReadlineKeyHandler -Chord 'Control+a' -ScriptBlock {
  [Console]::SetCursorPosition(5, 5)
}
  1. Set prompt to null
function prompt { "`0" }
  1. Clear screen. Your cursor should now be in the top left corner
Clear-Host
  1. Hit Ctrl+a. Your cursor should now be at position 5,5

  2. Type Write-Output

Expected behavior

The shell would display Write-Output starting at position 5,5

Actual behavior

The cursor moves back to position 1,1 and displays Write-Output there

Dominant language
C#
Stars
4.4k
Forks
341
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PowerShell/PSReadLine

All issues in PowerShell/PSReadLine

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.