hyperlinked_grep: Ensure filename is always printed
Fixes hyperlinks not working when a single file is searched
This commit is contained in:
parent
d09666aba9
commit
8bea61cb99
@ -53,3 +53,9 @@ actions, :doc:`see here <../open_actions>`.
|
||||
Hopefully, someday this functionality will make it into some `upstream grep
|
||||
<https://github.com/BurntSushi/ripgrep/issues/665>`_
|
||||
program directly removing the need for this kitten.
|
||||
|
||||
|
||||
.. note::
|
||||
While you can pass any of ripgrep's comand line options to the kitten and
|
||||
they will be forwarded to rg, do not use options that change the output
|
||||
formatting as the kitten works by parsing the output from ripgrep.
|
||||
|
||||
@ -25,7 +25,7 @@ def write_hyperlink(write: Callable[[bytes], None], url: bytes, line: bytes, fra
|
||||
def main() -> None:
|
||||
if not sys.stdout.isatty() and '--pretty' not in sys.argv:
|
||||
os.execlp('rg', 'rg', *sys.argv[1:])
|
||||
cmdline = ['rg', '--pretty'] + sys.argv[1:]
|
||||
cmdline = ['rg', '--pretty', '--with-filename'] + sys.argv[1:]
|
||||
p = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
|
||||
assert p.stdout is not None
|
||||
write: Callable[[bytes], None] = cast(Callable[[bytes], None], sys.stdout.buffer.write)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user