Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editing with context #372

Open
mcg opened this issue Sep 25, 2020 · 7 comments
Open

Editing with context #372

mcg opened this issue Sep 25, 2020 · 7 comments
Labels

Comments

@mcg
Copy link

mcg commented Sep 25, 2020

  • Emacs version: 27.1
  • Operating system: macOS
  • Search command(ag, pt, ack etc) and version: rg 12.1.1
  • Current helm-ag

This was added back in #214, but I doesn't seem to work now.

Actual behavior

Only able to edit matched line.

Expected behavior

Able to edit matched line and context lines

Steps to reproduce

Issue helm-do-project-root within a valid project directory.
Add a context switch to the search "-A/-B/-C".
Open search results in edit mode.
Only matched lines are editable, context is readonly.

@syohex
Copy link
Contributor

syohex commented Sep 27, 2020

I'm not sure your issue is fixed by a following patch

diff --git a/helm-ag.el b/helm-ag.el
index 8952c04..fd059df 100644
--- a/helm-ag.el
+++ b/helm-ag.el
@@ -613,7 +613,8 @@ Default behaviour shows finish and result in mode-line."
   ;; $3: match body
   ;; $4: file attributes part(filename, line, column)
   (cond ((helm-ag--vimgrep-option)
-         "^\\(?4:\\(?1:[^:]+\\):\\(?2:[1-9][0-9]*\\):[^:]+:\\)\\(?3:.*\\)$")
+         ;; context mode in --vimgrep flag like, filename-line-content
+         "^\\(?4:\\(?:\\(?1:[^\n:]+\\):\\(?2:[1-9][0-9]*\\):\\([^:\n]+:\\)\\|\\(?1:.+\\)-\\(?2:[1-9][0-9]*\\)-\\)\\)\\(?3:[^\n]*\\)$")
         (helm-ag--search-this-file-p
          "^\\(?4:\\(?2:[1-9][0-9]*\\)[:-]\\)\\(?3:.*\\)$")
         (t

@jcs090218 jcs090218 added the bug label Sep 28, 2020
@jcs090218
Copy link
Collaborator

@mcg Can you try the patch from @syohex ? And see if the patch works? Thanks! 😄

@mcg
Copy link
Author

mcg commented Sep 28, 2020

Sorry for the delay. Have tried the patch and the results are still read only, other than the match.

@syohex
Copy link
Contributor

syohex commented Sep 28, 2020

@mcg Could you show me your configuration and helm-ag--last-command value after helm-ag commands

@mcg
Copy link
Author

mcg commented Sep 28, 2020

Switched back to ag and have tried with and without --vimgrep no difference.

("ag" "--vimgrep" "-A5" "(?=.*backend.*)(?=.*\"s3\".*)")

@syohex
Copy link
Contributor

syohex commented Sep 28, 2020

Hmm, ag output is strange when both context option and --vimgrep option are specified(ag bug?? The format of context lines are not vim-grep style). While rg generates expected output with both options and ag without vimgrep option looks good too.

@syohex
Copy link
Contributor

syohex commented Sep 29, 2020

ggreer/the_silver_searcher#1409

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants