Fix off-by-one error in new commandline --column

parse_util_lineno() returns 1-based line numbers but
parse_util_get_offset_from_line() expects zero based line offsets.

Fixes #11162

(cherry picked from commit afbdb9f268)
This commit is contained in:
Johannes Altmanninger
2025-02-19 10:17:41 +01:00
parent ebc460b9f9
commit e2a0b0e2b8

View File

@@ -475,7 +475,7 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
rstate.cursor_pos + 1
- parse_util_get_offset_from_line(
&rstate.text,
i32::try_from(parse_util_lineno(&rstate.text, rstate.cursor_pos))
i32::try_from(parse_util_lineno(&rstate.text, rstate.cursor_pos) - 1)
.unwrap(),
)
.unwrap_or_default()