mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-04-16 00:26:04 +02:00
Ported: Fix color region end key seach and start key order.
- Paulb23
6cdcdbc242
This commit is contained in:
parent
6ea9b581d7
commit
a79792ee67
@ -155,18 +155,16 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting(int p_line)
|
|||||||
|
|
||||||
/* if we are in one find the end key */
|
/* if we are in one find the end key */
|
||||||
if (in_region != -1) {
|
if (in_region != -1) {
|
||||||
/* check there is enough room */
|
|
||||||
int chars_left = line_length - from;
|
|
||||||
int end_key_length = color_regions[in_region].end_key.length();
|
|
||||||
if (chars_left < end_key_length) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* search the line */
|
/* search the line */
|
||||||
int region_end_index = -1;
|
int region_end_index = -1;
|
||||||
const CharType *end_key = color_regions[in_region].start_key.get_data();
|
int end_key_length = color_regions[in_region].end_key.length();
|
||||||
|
const CharType *end_key = color_regions[in_region].end_key.get_data();
|
||||||
for (; from < line_length; from++) {
|
for (; from < line_length; from++) {
|
||||||
if (!is_a_symbol) {
|
if (line_length - from < end_key_length) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_symbol(str[from])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,9 +173,10 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting(int p_line)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
region_end_index = from;
|
||||||
for (int k = 0; k < end_key_length; k++) {
|
for (int k = 0; k < end_key_length; k++) {
|
||||||
if (end_key[k] == str[from + k]) {
|
if (end_key[k] != str[from + k]) {
|
||||||
region_end_index = from;
|
region_end_index = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,7 +193,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting(int p_line)
|
|||||||
previous_type = REGION;
|
previous_type = REGION;
|
||||||
previous_text = "";
|
previous_text = "";
|
||||||
previous_column = j;
|
previous_column = j;
|
||||||
j = from;
|
j = from + (end_key_length - 1);
|
||||||
if (region_end_index == -1) {
|
if (region_end_index == -1) {
|
||||||
color_region_cache[p_line] = in_region;
|
color_region_cache[p_line] = in_region;
|
||||||
}
|
}
|
||||||
@ -591,8 +590,13 @@ void GDScriptSyntaxHighlighter::add_color_region(const String &p_start_key, cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int at = 0;
|
||||||
for (int i = 0; i < color_regions.size(); i++) {
|
for (int i = 0; i < color_regions.size(); i++) {
|
||||||
ERR_FAIL_COND_MSG(color_regions[i].start_key == p_start_key, "color region with start key '" + p_start_key + "' already exists.");
|
ERR_FAIL_COND_MSG(color_regions[i].start_key == p_start_key, "color region with start key '" + p_start_key + "' already exists.");
|
||||||
|
|
||||||
|
if (p_start_key.length() < color_regions[i].start_key.length()) {
|
||||||
|
at++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorRegion color_region;
|
ColorRegion color_region;
|
||||||
@ -600,7 +604,8 @@ void GDScriptSyntaxHighlighter::add_color_region(const String &p_start_key, cons
|
|||||||
color_region.start_key = p_start_key;
|
color_region.start_key = p_start_key;
|
||||||
color_region.end_key = p_end_key;
|
color_region.end_key = p_end_key;
|
||||||
color_region.line_only = p_line_only;
|
color_region.line_only = p_line_only;
|
||||||
color_regions.push_back(color_region);
|
color_regions.insert(at, color_region);
|
||||||
|
clear_highlighting_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<EditorSyntaxHighlighter> GDScriptSyntaxHighlighter::_create() const {
|
Ref<EditorSyntaxHighlighter> GDScriptSyntaxHighlighter::_create() const {
|
||||||
|
@ -241,18 +241,16 @@ Dictionary CodeHighlighter::_get_line_syntax_highlighting(int p_line) {
|
|||||||
|
|
||||||
/* if we are in one find the end key */
|
/* if we are in one find the end key */
|
||||||
if (in_region != -1) {
|
if (in_region != -1) {
|
||||||
/* check there is enough room */
|
|
||||||
int chars_left = line_length - from;
|
|
||||||
int end_key_length = color_regions[in_region].end_key.length();
|
|
||||||
if (chars_left < end_key_length) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* search the line */
|
/* search the line */
|
||||||
int region_end_index = -1;
|
int region_end_index = -1;
|
||||||
const CharType *end_key = color_regions[in_region].start_key.get_data();
|
int end_key_length = color_regions[in_region].end_key.length();
|
||||||
|
const CharType *end_key = color_regions[in_region].end_key.get_data();
|
||||||
for (; from < line_length; from++) {
|
for (; from < line_length; from++) {
|
||||||
if (!is_a_symbol) {
|
if (line_length - from < end_key_length) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_symbol(str[from])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,9 +259,10 @@ Dictionary CodeHighlighter::_get_line_syntax_highlighting(int p_line) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
region_end_index = from;
|
||||||
for (int k = 0; k < end_key_length; k++) {
|
for (int k = 0; k < end_key_length; k++) {
|
||||||
if (end_key[k] == str[from + k]) {
|
if (end_key[k] != str[from + k]) {
|
||||||
region_end_index = from;
|
region_end_index = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -277,7 +276,7 @@ Dictionary CodeHighlighter::_get_line_syntax_highlighting(int p_line) {
|
|||||||
highlighter_info["color"] = color_regions[in_region].color;
|
highlighter_info["color"] = color_regions[in_region].color;
|
||||||
color_map[j] = highlighter_info;
|
color_map[j] = highlighter_info;
|
||||||
|
|
||||||
j = from;
|
j = from + (end_key_length - 1);
|
||||||
if (region_end_index == -1) {
|
if (region_end_index == -1) {
|
||||||
color_region_cache[p_line] = in_region;
|
color_region_cache[p_line] = in_region;
|
||||||
}
|
}
|
||||||
@ -498,8 +497,13 @@ void CodeHighlighter::add_color_region(const String &p_start_key, const String &
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
int at = 0;
|
||||||
for (int i = 0; i < color_regions.size(); i++) {
|
for (int i = 0; i < color_regions.size(); i++) {
|
||||||
ERR_FAIL_COND_MSG(color_regions[i].start_key == p_start_key, "color region with start key '" + p_start_key + "' already exists.");
|
ERR_FAIL_COND_MSG(color_regions[i].start_key == p_start_key, "color region with start key '" + p_start_key + "' already exists.");
|
||||||
|
|
||||||
|
if (p_start_key.length() < color_regions[i].start_key.length()) {
|
||||||
|
at++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorRegion color_region;
|
ColorRegion color_region;
|
||||||
@ -507,7 +511,7 @@ void CodeHighlighter::add_color_region(const String &p_start_key, const String &
|
|||||||
color_region.start_key = p_start_key;
|
color_region.start_key = p_start_key;
|
||||||
color_region.end_key = p_end_key;
|
color_region.end_key = p_end_key;
|
||||||
color_region.line_only = p_line_only;
|
color_region.line_only = p_line_only;
|
||||||
color_regions.push_back(color_region);
|
color_regions.insert(at, color_region);
|
||||||
clear_highlighting_cache();
|
clear_highlighting_cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user