mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
fix(query_error): multiline bug
This commit is contained in:
parent
845d5b8b64
commit
dd0e77d48a
@ -1582,25 +1582,19 @@ static void query_err_string(const char *src, int error_offset, TSQueryError err
|
|||||||
int error_line_len = 0;
|
int error_line_len = 0;
|
||||||
|
|
||||||
const char *end_str;
|
const char *end_str;
|
||||||
const char *src_tmp = src;
|
do {
|
||||||
while ((end_str = strchr(src_tmp, '\n')) != NULL) {
|
const char *src_tmp = src + line_start;
|
||||||
int line_length = (int)(end_str - src_tmp) + 1;
|
end_str = strchr(src_tmp, '\n');
|
||||||
|
int line_length = end_str != NULL ? (int)(end_str - src_tmp) : (int)strlen(src_tmp);
|
||||||
int line_end = line_start + line_length;
|
int line_end = line_start + line_length;
|
||||||
if (line_end > error_offset) {
|
if (line_end > error_offset) {
|
||||||
error_line = src_tmp;
|
error_line = src_tmp;
|
||||||
error_line_len = line_length;
|
error_line_len = line_length;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
line_start = line_end;
|
line_start = line_end + 1;
|
||||||
row++;
|
row++;
|
||||||
src_tmp += line_length;
|
} while (end_str != NULL);
|
||||||
}
|
|
||||||
|
|
||||||
// Additional check for the last line
|
|
||||||
if (line_start <= error_offset) {
|
|
||||||
error_line = src_tmp;
|
|
||||||
error_line_len = (int)strlen(src_tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
int column = error_offset - line_start;
|
int column = error_offset - line_start;
|
||||||
|
|
||||||
|
@ -1090,9 +1090,9 @@ int x = INT_MAX;
|
|||||||
|
|
||||||
-- Invalid capture name
|
-- Invalid capture name
|
||||||
test(
|
test(
|
||||||
'.../query.lua:0: Query error at 1:30. Invalid capture name "ok.capture":\n'..
|
'.../query.lua:0: Query error at 3:2. Invalid capture name "ok.capture":\n'..
|
||||||
'((identifier) @id (#eq? @id @ok.capture))\n'..
|
'@ok.capture\n'..
|
||||||
' ^',
|
' ^',
|
||||||
'((identifier) @id (#eq? @id @ok.capture))')
|
'((identifier) @id \n(#eq? @id\n@ok.capture\n))')
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user