Apply suggestions from code review
Small adjustments, as suggested by linus. Co-authored-by: Linus Groh <mail@linusgroh.de>
This commit is contained in:
parent
f4f12982ff
commit
3a5a9a683f
Notes:
sideshowbarker
2024-07-18 21:20:10 +09:00
Author: https://github.com/ElDonad Commit: https://github.com/SerenityOS/serenity/commit/3a5a9a683f4 Pull-request: https://github.com/SerenityOS/serenity/pull/5593 Reviewed-by: https://github.com/linusg ✅
2 changed files with 5 additions and 5 deletions
Userland/Services/LaunchServer
|
@ -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<String, String>& user_preferences, const String key, const AK::Vector<String> arguments, const String default_program)
|
||||
bool Launcher::open_with_user_preferences(const HashMap<String, String>& user_preferences, const String& key, const Vector<String>& 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<String> 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");
|
||||
|
|
|
@ -72,7 +72,7 @@ private:
|
|||
void for_each_handler(const String& key, HashMap<String, String>& user_preferences, Function<bool(const Handler&)> f);
|
||||
void for_each_handler_for_path(const String&, Function<bool(const Handler&)> f);
|
||||
bool open_file_url(const URL&);
|
||||
bool open_with_user_preferences(const HashMap<String, String>& user_preferences, const String key, const AK::Vector<String> arguments, const String default_program = {});
|
||||
bool open_with_user_preferences(const HashMap<String, String>& user_preferences, const String& key, const Vector<String>& arguments, const String& default_program = {});
|
||||
bool open_with_handler_name(const URL&, const String& handler_name);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue