Skip to content

Commit b29fbe9

Browse files
networkExceptionlinusg
authored andcommitted
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.
1 parent 4abb431 commit b29fbe9

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

Userland/Libraries/LibVT/TerminalWidget.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -831,13 +831,22 @@ void TerminalWidget::mousemove_event(GUI::MouseEvent& event)
831831

832832
auto handlers = Desktop::Launcher::get_handlers_for_url(attribute.href);
833833
if (!handlers.is_empty()) {
834-
auto path = URL(attribute.href).path();
835-
auto name = LexicalPath::basename(path);
836-
if (path == handlers[0]) {
837-
set_tooltip(String::formatted("Execute {}", name));
834+
auto url = URL(attribute.href);
835+
auto path = url.path();
836+
837+
auto app_file = Desktop::AppFile::get_for_app(LexicalPath::basename(handlers[0]));
838+
auto app_name = app_file->is_valid() ? app_file->name() : LexicalPath::basename(handlers[0]);
839+
840+
if (url.scheme() == "file") {
841+
auto file_name = LexicalPath::basename(path);
842+
843+
if (path == handlers[0]) {
844+
set_tooltip(String::formatted("Execute {}", app_name));
845+
} else {
846+
set_tooltip(String::formatted("Open {} with {}", file_name, app_name));
847+
}
838848
} else {
839-
auto af = Desktop::AppFile::get_for_app(LexicalPath::basename(handlers[0]));
840-
set_tooltip(String::formatted("Open {} with {}", name, af->is_valid() ? af->name() : LexicalPath::basename(handlers[0])));
849+
set_tooltip(String::formatted("Open {} with {}", attribute.href, app_name));
841850
}
842851
}
843852
} else {

0 commit comments

Comments
 (0)