ScriptTextEditor: fix capitalize offset

(cherry picked from commit caa0d513ab)
This commit is contained in:
Poommetee Ketson 2018-03-12 01:37:41 +07:00 committed by Hein-Pieter van Braam
parent 80fbea28fb
commit 72350eebb2
1 changed files with 8 additions and 3 deletions

View File

@ -349,7 +349,12 @@ void ScriptTextEditor::_convert_case(CaseStyle p_case) {
int end_col = te->get_selection_to_column(); int end_col = te->get_selection_to_column();
for (int i = begin; i <= end; i++) { for (int i = begin; i <= end; i++) {
String new_line = te->get_line(i); int len = te->get_line(i).length();
if (i == end)
len -= len - end_col;
if (i == begin)
len -= begin_col;
String new_line = te->get_line(i).substr(i == begin ? begin_col : 0, len);
switch (p_case) { switch (p_case) {
case UPPER: { case UPPER: {
@ -364,10 +369,10 @@ void ScriptTextEditor::_convert_case(CaseStyle p_case) {
} }
if (i == begin) { if (i == begin) {
new_line = te->get_line(i).left(begin_col) + new_line.right(begin_col); new_line = te->get_line(i).left(begin_col) + new_line;
} }
if (i == end) { if (i == end) {
new_line = new_line.left(end_col) + te->get_line(i).right(end_col); new_line = new_line + te->get_line(i).right(end_col);
} }
te->set_line(i, new_line); te->set_line(i, new_line);
} }