From 4846871a5cb464bb779fb4200b6b3a2f160cc241 Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Fri, 13 Jan 2023 09:56:15 +0100 Subject: [PATCH] Fix handling of percent signs by gui.popupTip() Since commit e41c0f099b87, the Tooltip class has performed string interpolation (i.e., sprintf()-style formatting) regardless of whether a was specified for the tooltip. This broke the API of gui.popupTip(): all '%' characters in the message had to be doubled to work as before. This commit restores the normal behavior of gui.popupTip() where '%' characters aren't interpreted in any special way. --- Nasal/gui.nas | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Nasal/gui.nas b/Nasal/gui.nas index 33fea8794..33c741fdc 100644 --- a/Nasal/gui.nas +++ b/Nasal/gui.nas @@ -11,7 +11,15 @@ var popupTip = func(label, delay = nil, override = nil, position = nil) if (position == nil) { position = {}; } - fgcommand("show-message", props.Node.new({ "label": label, "delay":delay, "x": position['x'], "y": position['y'] })); + + # Percent signs must be doubled because 'show-message' uses sprintf() on + # the label. + fgcommand("show-message", + props.Node.new( + {"label": string.replace(label, "%", "%%"), + "delay": delay, + "x": position['x'], + "y": position['y']})); } var showDialog = func(name) {