emacsorphanage / helm-ag

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

`helm-do-ag` breaks in hs-minor-mode on this specific source file #389

Open Davidj361 opened 2 years ago

Davidj361 commented 2 years ago

Actual behavior

https://github.com/syl20bnr/spacemacs/issues/15437

https://user-images.githubusercontent.com/10195356/161143440-7374cb43-5ac6-49da-a4a3-fa6cb526d2e2.mp4

Doing helm-do-ag in hs-minor-mode and searching for 'supp' in this code gives an error of: Search failed: there is an unmatched expression somewhere or we are at the beginning/end of file. [4 times]

void foobar(Foo1 * foo1, Bar1 * bar2)
{
    if (((foo->supp)&&(foo1->sec || d.s ||
        (foo->offset &&
            (abs(bar2->sec) >=
          foo->offset)))) || ((!foo->supp) && (foo1->sec))){
}

A comment from the spacemacs issue:

The issue comes from hs-minor-mode which is used by helm internally which seems to have an issue with the open curly bracket.

The build in version of this package is used in spacemacs-evil therefore its active. Please open a bug report upstream.

Edit:
As a fast workaround you can disable this mode, then helm will not use it and the error should be gone.

Expected behavior

When I jump to the entry it should take me to the correct line such as line 3.

Steps to reproduce

  1. Create /tmp/emacs
  2. Create this file /tmp/emacs/.emacs
    
    (setq-default indent-tabs-mode nil)

(require 'package)

(setq package-archives '( ;; ("gnu" . "https://elpa.gnu.org/packages/") ("melpa" . "https://melpa.org/packages/") ;; ("nongnu" . "https://elpa.nongnu.org/nongnu/") ))

(let ((my-pkgs '(helm helm-ag))) (when (seq-remove 'package-installed-p my-pkgs) (package-refresh-contents) (mapc (lambda (pkg) (package-install pkg t)) my-pkgs)))

(global-set-key (kbd "M-x") #'helm-M-x) (global-set-key (kbd "C-x r b") #'helm-filtered-bookmarks) (global-set-key (kbd "C-x C-f") #'helm-find-files) (setq helm-ag-base-command "rg --smart-case --no-heading --color=never")

(helm-mode 1)


3. `HOME=/tmp/emacs emacs`
4. Open a `test.c` with the code above
5. Enable `hs-minor-mode` in buffer
6. `helm-do-ag` and search for 'supp'