summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibVT/TerminalWidget.cpp
diff options
context:
space:
mode:
authornetworkException <git@nwex.de>2022-09-04 22:20:16 +0200
committerLinus Groh <mail@linusgroh.de>2022-09-05 09:23:20 +0100
commitb29fbe96ddbedb23756341b326074c9377f5cbc2 (patch)
tree414693c271f9cc6581d32de6c1c50ac92644d01b /Userland/Libraries/LibVT/TerminalWidget.cpp
parent4abb4317aa944d0eb61c1db74ed046bdafec9119 (diff)
downloadserenity-b29fbe96ddbedb23756341b326074c9377f5cbc2.zip
LibVT: Handle non file urls in on hover tooltips
Previously we would simply compute the basename of the hovered url's path and display it as the resource that will be opened. This patch adds a fallback for non file urls to simply show the full url, making http urls show up properly.
Diffstat (limited to 'Userland/Libraries/LibVT/TerminalWidget.cpp')
-rw-r--r--Userland/Libraries/LibVT/TerminalWidget.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/Userland/Libraries/LibVT/TerminalWidget.cpp b/Userland/Libraries/LibVT/TerminalWidget.cpp
index bc544d6336..0e0b44c3b6 100644
--- a/Userland/Libraries/LibVT/TerminalWidget.cpp
+++ b/Userland/Libraries/LibVT/TerminalWidget.cpp
@@ -831,13 +831,22 @@ void TerminalWidget::mousemove_event(GUI::MouseEvent& event)
auto handlers = Desktop::Launcher::get_handlers_for_url(attribute.href);
if (!handlers.is_empty()) {
- auto path = URL(attribute.href).path();
- auto name = LexicalPath::basename(path);
- if (path == handlers[0]) {
- set_tooltip(String::formatted("Execute {}", name));
+ auto url = URL(attribute.href);
+ auto path = url.path();
+
+ auto app_file = Desktop::AppFile::get_for_app(LexicalPath::basename(handlers[0]));
+ auto app_name = app_file->is_valid() ? app_file->name() : LexicalPath::basename(handlers[0]);
+
+ if (url.scheme() == "file") {
+ auto file_name = LexicalPath::basename(path);
+
+ if (path == handlers[0]) {
+ set_tooltip(String::formatted("Execute {}", app_name));
+ } else {
+ set_tooltip(String::formatted("Open {} with {}", file_name, app_name));
+ }
} else {
- auto af = Desktop::AppFile::get_for_app(LexicalPath::basename(handlers[0]));
- set_tooltip(String::formatted("Open {} with {}", name, af->is_valid() ? af->name() : LexicalPath::basename(handlers[0])));
+ set_tooltip(String::formatted("Open {} with {}", attribute.href, app_name));
}
}
} else {