Only emit resize event when size changed (#10419)

Currently, terminal will emit resize event every seconds, even if the
size not changed.
this PR fixed only emit resize event when size is changed.

Release Notes:

- N/A
This commit is contained in:
CharlesChen0823 2024-04-13 03:18:56 +08:00 committed by GitHub
parent f3a78f613a
commit 4e6f24a841
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -142,7 +142,7 @@ pub fn init(cx: &mut AppContext) {
TerminalSettings::register(cx);
}
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct TerminalSize {
pub cell_width: Pixels,
pub line_height: Pixels,
@ -992,7 +992,9 @@ impl Terminal {
///Resize the terminal and the PTY.
pub fn set_size(&mut self, new_size: TerminalSize) {
self.events.push_back(InternalEvent::Resize(new_size))
if self.last_content.size != new_size {
self.events.push_back(InternalEvent::Resize(new_size))
}
}
///Write the Input payload to the tty.