Make hyperlinked_grep kitten respect context
Fix regex so that context lines (from -C option) are still hyperlinked. Also add a case so that any non-matching lines are still output raw.
This commit is contained in:
parent
e337fcaadc
commit
bb3a8453e0
@ -29,7 +29,7 @@ def main() -> None:
|
||||
write: Callable[[bytes], None] = cast(Callable[[bytes], None], sys.stdout.buffer.write)
|
||||
sgr_pat = re.compile(br'\x1b\[.*?m')
|
||||
osc_pat = re.compile(b'\x1b\\].*?\x1b\\\\')
|
||||
num_pat = re.compile(b'^(\\d+):')
|
||||
num_pat = re.compile(b'^(\\d+)[:\\-]')
|
||||
|
||||
in_result: bytes = b''
|
||||
hostname = socket.gethostname().encode('utf-8')
|
||||
@ -46,6 +46,8 @@ def main() -> None:
|
||||
m = num_pat.match(clean_line)
|
||||
if m is not None:
|
||||
write_hyperlink(write, in_result, line, frag=m.group(1))
|
||||
else:
|
||||
write(line)
|
||||
else:
|
||||
if line.strip():
|
||||
path = quote_from_bytes(os.path.abspath(clean_line)).encode('utf-8')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user