summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorKarol Kosek <krkk@krkk.ct8.pl>2021-07-14 17:10:05 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-14 18:25:36 +0200
commit871c51dfd36fd83c0601b4ac9d9f2e157609a77b (patch)
treeb9508a1e6ff445468a466a775123b8b8dd7dbe0d /Userland/Libraries
parentc144d358ae6681a6b5fd208299ebc3d3a12c85c7 (diff)
downloadserenity-871c51dfd36fd83c0601b4ac9d9f2e157609a77b.zip
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.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGfx/Painter.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp
index 8552204678..3e93f9dd50 100644
--- a/Userland/Libraries/LibGfx/Painter.cpp
+++ b/Userland/Libraries/LibGfx/Painter.cpp
@@ -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]);