emacsorphanage / helm-ag

The silver searcher with helm interface
492 stars 76 forks source link

Editing with context #372

Open mcg opened 4 years ago

mcg commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

mcg commented 4 years ago

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

syohex commented 4 years ago

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

mcg commented 4 years ago

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

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

syohex commented 4 years ago

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 commented 4 years ago

https://github.com/ggreer/the_silver_searcher/pull/1409