Change behavior of String.right

This commit is contained in:
Tomasz Chabora
2020-02-13 16:42:49 +01:00
committed by kobewi
parent 78d85de13b
commit b1859510ab
16 changed files with 57 additions and 36 deletions
+3 -3
View File
@@ -1012,7 +1012,7 @@ void CodeTextEditor::convert_indent_to_spaces() {
if (cursor_line == i && cursor_column > j) {
cursor_column += indent_size - 1;
}
line = line.left(j) + indent + line.right(j + 1);
line = line.left(j) + indent + line.substr(j + 1);
}
j++;
}
@@ -1056,7 +1056,7 @@ void CodeTextEditor::convert_indent_to_tabs() {
if (cursor_line == i && cursor_column > j) {
cursor_column -= indent_size;
}
line = line.left(j - indent_size) + "\t" + line.right(j + 1);
line = line.left(j - indent_size) + "\t" + line.substr(j + 1);
j = 0;
space_count = -1;
}
@@ -1114,7 +1114,7 @@ void CodeTextEditor::convert_case(CaseStyle p_case) {
new_line = text_editor->get_line(i).left(begin_col) + new_line;
}
if (i == end) {
new_line = new_line + text_editor->get_line(i).right(end_col);
new_line = new_line + text_editor->get_line(i).substr(end_col);
}
text_editor->set_line(i, new_line);
}
+1 -1
View File
@@ -475,7 +475,7 @@ void EditorHelp::_update_doc() {
String linktxt = (cd.tutorials[i].title.is_empty()) ? link : DTR(cd.tutorials[i].title);
const int seppos = linktxt.find("//");
if (seppos != -1) {
linktxt = link.right(seppos + 2);
linktxt = link.substr(seppos + 2);
}
class_desc->push_color(symbol_color);
+1 -1
View File
@@ -334,7 +334,7 @@ bool EditorHelpSearch::Runner::_phase_match_classes() {
for (int i = 0; i < class_doc.methods.size(); i++) {
String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.methods[i].name : class_doc.methods[i].name.to_lower();
if (method_name.find(term) > -1 ||
(term.begins_with(".") && method_name.begins_with(term.right(1))) ||
(term.begins_with(".") && method_name.begins_with(term.substr(1))) ||
(term.ends_with("(") && method_name.ends_with(term.left(term.length() - 1).strip_edges())) ||
(term.begins_with(".") && term.ends_with("(") && method_name == term.substr(1, term.length() - 2).strip_edges())) {
match.methods.push_back(const_cast<DocData::MethodDoc *>(&class_doc.methods[i]));
+2 -2
View File
@@ -1809,12 +1809,12 @@ void EditorInspector::update_tree() {
basename = group + "/" + basename;
}
String name = (basename.find("/") != -1) ? basename.right(basename.rfind("/") + 1) : basename;
String name = (basename.find("/") != -1) ? basename.substr(basename.rfind("/") + 1) : basename;
if (capitalize_paths) {
int dot = name.find(".");
if (dot != -1) {
String ov = name.right(dot);
String ov = name.substr(dot);
name = name.substr(0, dot);
name = name.capitalize();
name += ov;
+2 -2
View File
@@ -530,7 +530,7 @@ void FindInFilesDialog::_on_replace_text_entered(String text) {
void FindInFilesDialog::_on_folder_selected(String path) {
int i = path.find("://");
if (i != -1) {
path = path.right(i + 3);
path = path.substr(i + 3);
}
_folder_line_edit->set_text(path);
}
@@ -932,7 +932,7 @@ void FindInFilesPanel::apply_replaces_in_file(String fpath, const Vector<Result>
continue;
}
line = line.left(repl_begin) + new_text + line.right(repl_end);
line = line.left(repl_begin) + new_text + line.substr(repl_end);
// keep an offset in case there are successive replaces in the same line
offset += new_text.length() - (repl_end - repl_begin);
}
+2 -2
View File
@@ -2138,8 +2138,8 @@ void ProjectManager::_run_project_confirm() {
const String &selected = selected_list[i].project_key;
String path = EditorSettings::get_singleton()->get("projects/" + selected);
// `.right(6)` on `IMPORTED_FILES_PATH` strips away the leading "res://".
if (!DirAccess::exists(path.plus_file(ProjectSettings::IMPORTED_FILES_PATH.right(6)))) {
// `.substr(6)` on `IMPORTED_FILES_PATH` strips away the leading "res://".
if (!DirAccess::exists(path.plus_file(ProjectSettings::IMPORTED_FILES_PATH.substr(6)))) {
run_error_diag->set_text(TTR("Can't run project: Assets need to be imported.\nPlease edit the project to trigger the initial import."));
run_error_diag->popup_centered();
continue;