summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-11-07 10:02:29 +0100
committerGitHub <noreply@github.com>2022-11-07 10:02:29 +0100
commit92557a52b7c1fcaecbf41ea0af00dab4889cb1df (patch)
treee36c9dc0a4ccf6c5e67d9d8e0c3169506acd161b /editor
parent2c8498c8a6b242141201319af3021c878784c15c (diff)
parentf1743263d3e4f110245f710846a6efec72fd27ef (diff)
Merge pull request #68330 from RedMser/fix-relative-paths-disambiguate
Fix and simplify `EditorNode::disambiguate_filenames`
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_node.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 716e0b454f..a748572d2a 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -244,15 +244,11 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto
String full_path = p_full_paths[set_idx];
// Get rid of file extensions and res:// prefixes.
- if (scene_name.rfind(".") >= 0) {
- scene_name = scene_name.substr(0, scene_name.rfind("."));
- }
+ scene_name = scene_name.get_basename();
if (full_path.begins_with("res://")) {
full_path = full_path.substr(6);
}
- if (full_path.rfind(".") >= 0) {
- full_path = full_path.substr(0, full_path.rfind("."));
- }
+ full_path = full_path.get_basename();
// Normalize trailing slashes when normalizing directory names.
scene_name = scene_name.trim_suffix("/");
@@ -270,7 +266,7 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto
String parent = full_path.substr(0, difference);
int slash_idx = parent.rfind("/");
slash_idx = parent.rfind("/", slash_idx - 1);
- parent = slash_idx >= 0 ? parent.substr(slash_idx + 1) : parent;
+ parent = (slash_idx >= 0 && parent.length() > 1) ? parent.substr(slash_idx + 1) : parent;
r_filenames.write[set_idx] = parent + r_filenames[set_idx];
}
}
@@ -302,15 +298,11 @@ void EditorNode::disambiguate_filenames(const Vector<String> p_full_paths, Vecto
String path = p_full_paths[E->get()];
// Get rid of file extensions and res:// prefixes.
- if (scene_name.rfind(".") >= 0) {
- scene_name = scene_name.substr(0, scene_name.rfind("."));
- }
+ scene_name = scene_name.get_basename();
if (path.begins_with("res://")) {
path = path.substr(6);
}
- if (path.rfind(".") >= 0) {
- path = path.substr(0, path.rfind("."));
- }
+ path = path.get_basename();
// Normalize trailing slashes when normalizing directory names.
scene_name = scene_name.trim_suffix("/");