summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-03-13 09:55:15 +0100
committerGitHub <noreply@github.com>2018-03-13 09:55:15 +0100
commit965feb9521454f608fc040ec77754fbaf9ac7276 (patch)
tree980e5eb0380e1e46629c0e6b8ef33dc3541e79e5
parent15626fa2d08b8de4b75353a115c724b5b017d8d9 (diff)
parentcaa0d513ab89d46dbf694182ab47a77f5fbe31ed (diff)
Merge pull request #17455 from Noshyaar/capitalize
ScriptTextEditor: fix capitalize offset
-rw-r--r--editor/plugins/script_text_editor.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index aeba0ff930..c8ea2f79fe 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -349,7 +349,12 @@ void ScriptTextEditor::_convert_case(CaseStyle p_case) {
int end_col = te->get_selection_to_column();
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) {
case UPPER: {
@@ -364,10 +369,10 @@ void ScriptTextEditor::_convert_case(CaseStyle p_case) {
}
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) {
- 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);
}