From 813f6d4d58a471d6f393c0e0ef906216d16b402d Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Tue, 24 Dec 2024 22:55:05 -0500 Subject: [PATCH] reorganize logic to make better semantic sense This should be functionally identical, it just makes more sense written this way. When releasing the style we simultaneously clear the ID back to default, and after that point it's guaranteed to be default until changed again so we don't need to set it before returning if the new style is default or before adding the style to the new page. --- src/terminal/Screen.zig | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 47359a919..66438f231 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -1774,18 +1774,11 @@ pub fn manualStyleUpdate(self: *Screen) !void { // Release our previous style if it was not default. if (self.cursor.style_id != style.default_id) { page.styles.release(page.memory, self.cursor.style_id); - } - - // If our new style is the default, just reset to that - if (self.cursor.style.default()) { self.cursor.style_id = style.default_id; - return; } - // Clear the cursor style ID to prevent weird things from happening - // if the page capacity has to be adjusted which would end up calling - // manualStyleUpdate again. - self.cursor.style_id = style.default_id; + // If our new style is the default, then we're done. + if (self.cursor.style.default()) return; // After setting the style, we need to update our style map. // Note that we COULD lazily do this in print. We should look into