mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
Shell: Color bareword yellow if it's a prefix of at least one command
Before, if a bareword wasn't a runnable program's filename it got colored red and white otherwise. Now, additionally it will be checked if it is a "prefix" of a possible command and colored yellow if it is and red if not. Coloring this way provides another "feedback" to the user: If while typing out a command name the color changes from yellow to red then a typo occurred :^) To check if a bareword is a prefix the `Shell::complete_program_name()` function is utilized (if pressing tab gives you some suggestions then it is a prefix).
This commit is contained in:
parent
ad440f9e9a
commit
1453028975
Notes:
sideshowbarker
2024-07-17 03:45:48 +09:00
Author: https://github.com/ronak69 Commit: https://github.com/SerenityOS/serenity/commit/1453028975 Pull-request: https://github.com/SerenityOS/serenity/pull/20372 Reviewed-by: https://github.com/alimpfard ✅
1 changed files with 2 additions and 0 deletions
|
@ -654,6 +654,8 @@ ErrorOr<void> BarewordLiteral::highlight_in_editor(Line::Editor& editor, Shell&
|
|||
#endif
|
||||
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, style);
|
||||
} else if (auto suggestions = shell.complete_program_name(m_text, m_text.bytes().size()); !suggestions.is_empty()) {
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Foreground(Line::Style::XtermColor::Yellow) });
|
||||
} else {
|
||||
editor.stylize({ m_position.start_offset, m_position.end_offset }, { Line::Style::Foreground(Line::Style::XtermColor::Red) });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue