agent-shell icon indicating copy to clipboard operation
agent-shell copied to clipboard

agent-shell--get-region-context inserts a snippet that includes an extra line

Open bcc32 opened this issue 5 months ago • 0 comments

When the end of the region is at the beginning of a line, agent-shell--get-region-context includes the line following the end of the region, in both the line numbers and the snippet that get pasted into the shell buffer.

For example, in the LICENSE file in this repo, starting with point at the beginning of the buffer, press:

C-n C-n C-n C-SPC C-n C-n C-n M-x agent-shell

This inserts the following text:

LICENSE:4-7

   4:  Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
   5:  Everyone is permitted to copy and distribute verbatim copies
   6:  of this license document, but changing it is not allowed.
   7: 

Whereas I would have expected it to insert:

LICENSE:4-6

   4:  Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
   5:  Everyone is permitted to copy and distribute verbatim copies
   6:  of this license document, but changing it is not allowed.

By the way, this also affects evil-mode users when using line-based selections (V) because region-end naturally ends up at the beginning of the line following the actual selection.

Checklist

  • [X] I agree to communicate with the author myself (not AI-generated).
  • [X] I've read the README's Filing issues section.
  • [X] I'm running the latest versions (fill in below).
    • agent-shell version: 0.55.1
    • acp.el version: 0.12.2
    • ACP package (e.g. claude-agent-acp) version: N/A
    • Agent CLI (e.g. claude, gemini) version: N/A
  • [ ] For requesting new agent support, I'm including a link to the ACP-capable agent or related ACP package.
  • [ ] For issues, I'm including ACP traffic (as per README).

bcc32 avatar Jun 11 '26 22:06 bcc32