mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +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
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…
Add table
Add a link
Reference in a new issue