Fix TextEdit IME error on mouse over
This commit is contained in:
parent
7d7d479162
commit
290180c899
1 changed files with 12 additions and 15 deletions
|
|
@ -4974,7 +4974,7 @@ String TextEdit::get_word(int p_line, int p_column) const {
|
|||
}
|
||||
ERR_FAIL_INDEX_V(p_line, text.size(), String());
|
||||
|
||||
const String &text_line = text[p_line];
|
||||
const String &text_line = text.get_text_with_ime(p_line);
|
||||
if (text_line.is_empty()) {
|
||||
return String();
|
||||
}
|
||||
|
|
@ -6386,24 +6386,20 @@ int TextEdit::get_line_wrap_count(int p_line) const {
|
|||
int TextEdit::get_line_wrap_index_at_column(int p_line, int p_column) const {
|
||||
ERR_FAIL_INDEX_V(p_line, text.size(), 0);
|
||||
ERR_FAIL_COND_V(p_column < 0, 0);
|
||||
ERR_FAIL_COND_V(p_column > text[p_line].length(), 0);
|
||||
ERR_FAIL_COND_V(p_column > text.get_text_with_ime(p_line).length(), 0);
|
||||
|
||||
if (!is_line_wrapped(p_line)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Loop through wraps in the line text until we get to the column. */
|
||||
int wrap_index = 0;
|
||||
int col = 0;
|
||||
Vector<String> lines = get_line_wrapped_text(p_line);
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
wrap_index = i;
|
||||
col += lines[wrap_index].length();
|
||||
if (col > p_column) {
|
||||
break;
|
||||
// Loop through wraps in the line text until we get to the column.
|
||||
const Vector<Vector2i> line_ranges = text.get_line_wrap_ranges(p_line);
|
||||
for (int i = 0; i < line_ranges.size(); i++) {
|
||||
if (line_ranges[i].y > p_column) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return wrap_index;
|
||||
return line_ranges.is_empty() ? 0 : line_ranges.size() - 1;
|
||||
}
|
||||
|
||||
Vector<String> TextEdit::get_line_wrapped_text(int p_line) const {
|
||||
|
|
@ -6411,12 +6407,13 @@ Vector<String> TextEdit::get_line_wrapped_text(int p_line) const {
|
|||
|
||||
Vector<String> lines;
|
||||
if (!is_line_wrapped(p_line)) {
|
||||
lines.push_back(text[p_line]);
|
||||
lines.push_back(text.get_text_with_ime(p_line));
|
||||
return lines;
|
||||
}
|
||||
|
||||
const String &line_text = text[p_line];
|
||||
Vector<Vector2i> line_ranges = text.get_line_wrap_ranges(p_line);
|
||||
const String &line_text = text.get_text_with_ime(p_line);
|
||||
const Vector<Vector2i> line_ranges = text.get_line_wrap_ranges(p_line);
|
||||
lines.reserve(line_ranges.size());
|
||||
for (int i = 0; i < line_ranges.size(); i++) {
|
||||
lines.push_back(line_text.substr(line_ranges[i].x, line_ranges[i].y - line_ranges[i].x));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue