From 3a5a9a683f4fc50c57fbc075219dcc8c3ee03ab6 Mon Sep 17 00:00:00 2001 From: Elie Donadio Date: Mon, 15 Mar 2021 09:07:00 +0100 Subject: [PATCH] Apply suggestions from code review Small adjustments, as suggested by linus. Co-authored-by: Linus Groh --- Userland/Services/LaunchServer/Launcher.cpp | 8 ++++---- Userland/Services/LaunchServer/Launcher.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Userland/Services/LaunchServer/Launcher.cpp b/Userland/Services/LaunchServer/Launcher.cpp index 812b90e489..2641960cd5 100644 --- a/Userland/Services/LaunchServer/Launcher.cpp +++ b/Userland/Services/LaunchServer/Launcher.cpp @@ -225,7 +225,7 @@ Handler Launcher::get_handler_for_executable(Handler::Type handler_type, const S return handler; } -bool Launcher::open_with_user_preferences(const HashMap& user_preferences, const String key, const AK::Vector arguments, const String default_program) +bool Launcher::open_with_user_preferences(const HashMap& user_preferences, const String& key, const Vector& arguments, const String& default_program) { auto program_path = user_preferences.get(key); if (program_path.has_value()) @@ -318,16 +318,16 @@ bool Launcher::open_file_url(const URL& url) if (extension_parts.size() > 1) extension = extension_parts.last(); - // Additionnal parameters parsing, specific for the file protocol + // Additional parameters parsing, specific for the file protocol and TextEditor Vector additional_parameters; additional_parameters.append(url.path()); auto parameters = url.query().split('&'); for (auto parameter = parameters.begin(); parameter != parameters.end(); ++parameter) { auto pair = parameter->split('='); - if (pair[0] == "line_number") { + if (pair.size() == 2 && pair[0] == "line_number") { auto line = pair[1].to_int(); if (line.has_value()) - additional_parameters.prepend(String::format("-l%i", *line)); + additional_parameters.prepend(String::formatted("-l {}", line.value())); } } return open_with_user_preferences(m_file_handlers, extension, additional_parameters, "/bin/TextEditor"); diff --git a/Userland/Services/LaunchServer/Launcher.h b/Userland/Services/LaunchServer/Launcher.h index 46924f83b5..2160f95059 100644 --- a/Userland/Services/LaunchServer/Launcher.h +++ b/Userland/Services/LaunchServer/Launcher.h @@ -72,7 +72,7 @@ private: void for_each_handler(const String& key, HashMap& user_preferences, Function f); void for_each_handler_for_path(const String&, Function f); bool open_file_url(const URL&); - bool open_with_user_preferences(const HashMap& user_preferences, const String key, const AK::Vector arguments, const String default_program = {}); + bool open_with_user_preferences(const HashMap& user_preferences, const String& key, const Vector& arguments, const String& default_program = {}); bool open_with_handler_name(const URL&, const String& handler_name); }; }