Skip to content

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

@bcc32

Description

@bcc32

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

  • I agree to communicate with the author myself (not AI-generated).
  • I've read the README's Filing issues section.
  • 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions