Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 15, 2025

Addresses code duplication feedback from #48 where logic for computing region-end-line, git-relative-path, and region-location-info was duplicated between ai-code-discussion.el and ai-code-change.el.

Changes

  • Added ai-code--get-region-location-info helper function in ai-code-discussion.el that returns (region-end-line git-relative-path region-location-info) given region boundaries
  • Updated ai-code--ask-question-file and ai-code-code-change to use the helper instead of duplicating the logic
  • Added forward declaration in ai-code-change.el

Before:

(region-end-line (when region-active
                   (line-number-at-pos (region-end))))
(git-relative-path (when (and region-active buffer-file-name)
                    (car (ai-code--get-git-relative-paths (list buffer-file-name)))))
(region-location-info (when (and region-active git-relative-path region-start-line region-end-line)
                       (format "%s#L%d-L%d" git-relative-path region-start-line region-end-line)))

After:

(region-info (when region-active
              (ai-code--get-region-location-info (region-beginning) (region-end))))
(region-end-line (nth 0 region-info))
(git-relative-path (nth 1 region-info))
(region-location-info (nth 2 region-info))

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: tninja <714625+tninja@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on adding region location info in prompts Extract duplicated region location logic into shared helper function Nov 15, 2025
Copilot AI requested a review from tninja November 15, 2025 03:58
Copilot finished work on behalf of tninja November 15, 2025 03:58
@tninja tninja marked this pull request as ready for review November 15, 2025 15:57
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.

2 participants