浏览代码

Fix TextEdit color_region_cache bug

Due to a single error, _is_line_in_region was previously iterating over the color highlighting for the entire document repeatedly for each line in the script.

This is now fixed, which should make the editor much faster with large scripts.
lawnjelly 2 年之前
父节点
当前提交
57306bf0e3
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      scene/gui/text_edit.cpp

+ 1 - 1
scene/gui/text_edit.cpp

@@ -5488,7 +5488,7 @@ int TextEdit::_is_line_in_region(int p_line) {
 	// If not find the closest line we have.
 	// If not find the closest line we have.
 	int previous_line = p_line - 1;
 	int previous_line = p_line - 1;
 	for (; previous_line > -1; previous_line--) {
 	for (; previous_line > -1; previous_line--) {
-		if (color_region_cache.has(p_line)) {
+		if (color_region_cache.has(previous_line)) {
 			break;
 			break;
 		}
 		}
 	}
 	}