mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:27:45 +00:00
LibGfx: Don't underline escaped ampersand in menus
Double ampersands (&&) marking in menus is meant to provide a way to show the ampersand, since using just one would turn it into a modifier that sets the shortcut for the next character. Unfortunately, while the first character had a special case to avoid marking this set, the marking was still calculated for the second character. The fix is rather simple: just skip then the following character! This issue applied only to the visual part of the Menu. The WindowServer calculation for the shortcut character is working properly, i.e. ignores escaped ampersands.
This commit is contained in:
parent
c144d358ae
commit
871c51dfd3
1 changed files with 4 additions and 2 deletions
|
@ -2221,10 +2221,12 @@ String parse_ampersand_string(const StringView& raw_text, Optional<size_t>* unde
|
|||
|
||||
for (size_t i = 0; i < raw_text.length(); ++i) {
|
||||
if (raw_text[i] == '&') {
|
||||
if (i != (raw_text.length() - 1) && raw_text[i + 1] == '&')
|
||||
if (i != (raw_text.length() - 1) && raw_text[i + 1] == '&') {
|
||||
builder.append(raw_text[i]);
|
||||
else if (underline_offset && !(*underline_offset).has_value())
|
||||
++i;
|
||||
} else if (underline_offset && !(*underline_offset).has_value()) {
|
||||
*underline_offset = i;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
builder.append(raw_text[i]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue