number_input_story: Fix subtraction overflow (#976)

This commit is contained in:
Floyd Wang 2025-06-18 10:16:57 +08:00 committed by GitHub
parent a478f000d4
commit c39e7af50c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -155,7 +155,7 @@ impl NumberInputStory {
input.set_value(self.number_input1_value.to_string(), window, cx);
});
} else if this == &self.number_input2 {
self.number_input2_value = self.number_input2_value - 1;
self.number_input2_value = self.number_input2_value.saturating_sub(1);
this.update(cx, |input, cx| {
input.set_value(self.number_input2_value.to_string(), window, cx);
});