瀏覽代碼

Fix displaying error on wrong line with token at EOL

Previously, this would get a token on text like "\n*\n" where `*`
is the token's position, and it would advance off that line.
Feoramund 1 年之前
父節點
當前提交
ca481dc52d
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      src/parser.cpp

+ 6 - 0
src/parser.cpp

@@ -51,6 +51,12 @@ gb_internal gbString get_file_line_as_string(TokenPos const &pos, i32 *offset_)
 
 	u8 *line_start = pos_offset;
 	u8 *line_end  = pos_offset;
+
+	if (offset > 0 && *line_start == '\n') {
+		// Prevent an error token that starts at the boundary of a line that
+		// leads to an empty line from advancing off its line.
+		line_start -= 1;
+	}
 	while (line_start >= start) {
 		if (*line_start == '\n') {
 			line_start += 1;