commit 7d55c232d204fcd22ee1ba1838a3987afda4ea44
parent 053db625e9ddcc6c3b34a151fe83724507bdc7a1
Author: Lou Woell <lou.woell@posteo.de>
Date:   Mon,  6 Oct 2025 19:44:21 +0200

[find-refs] fix: reset file offset after getting line

Diffstat:
Mcmd/harehelper/find_refs.ha | 12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/cmd/harehelper/find_refs.ha b/cmd/harehelper/find_refs.ha @@ -48,19 +48,27 @@ fn print_ref (ref: xref) void = { fn get_line (file: io::handle, loc: *lex::location) (str | io::error) = { let off = loc.off; + const o_off = io::tell(file)!; + + // This is slow. + // TODO: figure out a way to get the line from the line/column info. for (true) { - io::seek(file, off, 0)!; + io::seek(file, off, io::whence::SET)!; let r = bufio::read_rune(file); if('\n' == r) break; off -= 1; }; - return match (bufio::read_line(file)?) { + let result = match (bufio::read_line(file)?) { case let b: []u8 => yield strings::fromutf8(b)!; case io::EOF => yield ""; }; + + io::seek(file, o_off, io::whence::SET)!; + + return result; }; fn find_refs (cmd: getopt::command, ctx: *module::context) void = {