1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builder: fix a bug in error_context_lines

This commit is contained in:
Delyan Angelov 2022-01-04 10:59:39 +02:00
parent 00a0c1886e
commit feadf777c3
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -941,12 +941,12 @@ fn missing_compiler_info() string {
fn error_context_lines(text string, keyword string, before int, after int) []string { fn error_context_lines(text string, keyword string, before int, after int) []string {
khighlight := if term.can_show_color_on_stdout() { term.red(keyword) } else { keyword } khighlight := if term.can_show_color_on_stdout() { term.red(keyword) } else { keyword }
mut eline_idx := 0 mut eline_idx := -1
mut lines := text.split_into_lines() mut lines := text.split_into_lines()
for idx, eline in lines { for idx, eline in lines {
if eline.contains(keyword) { if eline.contains(keyword) {
lines[idx] = lines[idx].replace(keyword, khighlight) lines[idx] = lines[idx].replace(keyword, khighlight)
if eline_idx == 0 { if eline_idx == -1 {
eline_idx = idx eline_idx = idx
} }
} }