Skip to content

Commit

Permalink
Use backslashes in absolute paths copied from the FileSystem dock on …
Browse files Browse the repository at this point in the history
…Windows

This results in paths that can be readily pasted in more Windows programs
compared to paths with forward slashes.
  • Loading branch information
Calinou committed Jul 2, 2024
1 parent 9425535 commit 2ebfdd0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions editor/filesystem_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2512,7 +2512,13 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
case FILE_COPY_ABSOLUTE_PATH: {
if (!p_selected.is_empty()) {
const String &fpath = p_selected[0];
#ifdef WINDOWS_ENABLED
// Replace forward slashes with backslashes to make copying to other programs easier,
// as many Windows programs only accept paths with backslashes.
const String absolute_path = ProjectSettings::get_singleton()->globalize_path(fpath).replace("/", "\\");
#else
const String absolute_path = ProjectSettings::get_singleton()->globalize_path(fpath);
#endif
DisplayServer::get_singleton()->clipboard_set(absolute_path);
}
} break;
Expand Down

0 comments on commit 2ebfdd0

Please sign in to comment.