deadgrep icon indicating copy to clipboard operation
deadgrep copied to clipboard

TAB does not hide all file entries when before=1

Open sje30 opened this issue 3 years ago • 0 comments

Hi, if I set the context before to something non-zero, e.g. 1 and then do a search, TAB does not hide all the entries in a file; it only hides the first entry.

e.g. if I am in the /etc folder of emacs and do a search for 'bidi' with before:1 then e.g. for the NEWS.25 file I get the folllowing entries:

Search term: bidi change
Search type: string words regexp
Case: smart sensitive ignore
Context: none before:1 after:0

Directory: /usr/local/share/emacs/28.0.90/etc/
Files: all type glob

NEWS.25
315  ** Emacs now supports the latest version of the UBA.
316  The Emacs implementation of the Unicode Bidirectional Algorithm (UBA)
---
319  This includes full support for directional isolates and the
320  Bidirectional Parentheses Algorithm (BPA) specified by these Unicode
---
1472 
1473 ** The new function 'bidi-find-overridden-directionality' allows you to
----
1476 can use this to detect potential phishing of URLs and other links that
1477 exploits bidirectional display reordering.
1478 
1479 ** The new function 'buffer-substring-with-bidi-context' allows you to
----
1481 the visual appearance both of the copied text and the text at
1482 destination, even when the copied text includes mixed bidirectional
----

NEWS.23
2228 character properties.  They are `name', `general-category',
2229 `canonical-combining-class', `bidi-class', `decomposition',
--

If I now hit TAB on NEWS.25, only lines 319 and 320 disappear. This is because in deadgrep--hide the stopping condition in the relevant loop is:

              (while (and
                      (get-text-property (point) 'deadgrep-line-number)
                      (not (bobp)))
                (forward-line))

and the --- separator lines in the output buffer that separate matches in one file do not have the text property deadgrep-line-number. Hence it hides only the first match.

About your environment:
Platform: gnu/linux
Emacs version: 28.0.90
Command: rg --color=ansi --line-number --no-heading --no-column --with-filename --fixed-strings --smart-case --before-context=1 --after-context=0 -- bidi .
default-directory: "/usr/local/share/emacs/28.0.90/etc/"
exec-path: ("/home/stephen/NOBACKUP/compiles/makefile2graph" "//home/stephen/langs/bin/python" "/home/stephen/langs/bin/perl" "//home/stephen/bin" "~/.local/bin" "/home/stephen/langs/bin/R" "/home/stephen/langs/bin/julia" "/home/stephen/langs/bin/sh" "/home/stephen/langs/bin/python" "/home/stephen/langs/bin/perl" "//home/stephen/bin" "/home/stephen/.local/bin" "/usr/local/bin" "/usr/bin" "/bin" "/usr/local/sbin" "/home/stephen/.dotnet/tools" "/usr/lib/jvm/default/bin" "/usr/bin/site_perl" "/usr/bin/vendor_perl" "/usr/bin/core_perl" "/home/stephen/langs/bin/applescript" "/home/stephen/langs/bin/sh" "/home/stephen/.gem/ruby/2.7.0/bin" "/usr/local/libexec/emacs/28.0.90/x86_64-pc-linux-gnu")
tramp-remote-path: (tramp-default-remote-path "/bin" "/usr/bin" "/sbin" "/usr/sbin" "/usr/local/bin" "/usr/local/sbin" "/local/bin" "/local/freeware/bin" "/local/gnu/bin" "/usr/freeware/bin" "/usr/pkg/bin" "/usr/contrib/bin" "/opt/bin" "/opt/sbin" "/opt/local/bin")

Initial output from ripgrep:
"[0m[35m./NEWS.25[0m-[0m[32m315[0m-** Emacs now supports the latest version of the UBA.
[0m[35m./NEWS.25[0m:[0m[32m316[0m:The Emacs implementation of the Unicode [0m[1m[31mBidi[0mrectional Algorithm (UBA)
--
[0m[35m./NEWS.25[0m-[0m[32m319[0m-This includes full support for directional isolates and the
[0m[35m./NEWS.25[0m:[0m[32m320[0m:[0m[1m[31mBidi[0mrectional Parentheses Algorithm (BPA) specified by these Unicode
--
[0m[35m./NEWS.25[0m-[0m[32m1472[0m-
[0m[35m./NEWS.25[0m:[0m[32m1473[0m:** The new function '[0m[1m[31mbidi[0m-find-overridden-directionality' allows you to
--
[0m[35m./NEWS.25[0m-[0m[32m1476[0m-can use this to detect potential phishing of URLs and other links that
[0m[35m./NEWS.25[0m:[0m[32m1477[0m:exploits [0m[1m[31mbidi[0mrectional display reordering.
[0m[35m./NEWS.25[0m-[0m[32m1478[0m-
[0m[35m./NEWS.25[0m:[0m[32m1479[0m:** The new function 'buffer-substring-with-[0m[1m[31mbidi[0m-context' allows you to
--
[0m[35m./NEWS.25[0m-[0m[32m1481[0m-the visual appearance both of the copied text and the text at
[0m[35m./NEWS.25[0m:[0m[32m1482[0m:destination, even when the copied text includes mixed [0m[1m[31mbidi[0mrectional
--
[0m[35m./NEWS.23[0m-[0m[32m2228[0m-character properties.  They are `name', `general-category',
[0m[35m./NEWS.23[0m:[0m[32m2229[0m:`canonical-combining-class', `[0m[1m[31mbidi[0m-class', `decomposition',
"

Please file bugs at https://github.com/Wilfred/deadgrep/issues/new

sje30 avatar Jan 15 '22 18:01 sje30