mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:57:35 +00:00
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
2 changed files with 5 additions and 5 deletions
|
@ -225,7 +225,7 @@ Handler Launcher::get_handler_for_executable(Handler::Type handler_type, const S
|
||||||
return handler;
|
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);
|
auto program_path = user_preferences.get(key);
|
||||||
if (program_path.has_value())
|
if (program_path.has_value())
|
||||||
|
@ -318,16 +318,16 @@ bool Launcher::open_file_url(const URL& url)
|
||||||
if (extension_parts.size() > 1)
|
if (extension_parts.size() > 1)
|
||||||
extension = extension_parts.last();
|
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;
|
Vector<String> additional_parameters;
|
||||||
additional_parameters.append(url.path());
|
additional_parameters.append(url.path());
|
||||||
auto parameters = url.query().split('&');
|
auto parameters = url.query().split('&');
|
||||||
for (auto parameter = parameters.begin(); parameter != parameters.end(); ++parameter) {
|
for (auto parameter = parameters.begin(); parameter != parameters.end(); ++parameter) {
|
||||||
auto pair = parameter->split('=');
|
auto pair = parameter->split('=');
|
||||||
if (pair[0] == "line_number") {
|
if (pair.size() == 2 && pair[0] == "line_number") {
|
||||||
auto line = pair[1].to_int();
|
auto line = pair[1].to_int();
|
||||||
if (line.has_value())
|
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");
|
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(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);
|
void for_each_handler_for_path(const String&, Function<bool(const Handler&)> f);
|
||||||
bool open_file_url(const URL&);
|
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);
|
bool open_with_handler_name(const URL&, const String& handler_name);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue