Skip to content

Commit 7d324c2

Browse files
committed
Fix flicker caused by action width change
When the longest action name changed, it would cause the action column in the list display to resize, causing a flicker. While this was intended behavior, it almost always caused a redraw, which was jarring. This changes the rendering of the action to keep the minimum draw width of the action at 6, to reduce the amount of flicker.
1 parent 401d96c commit 7d324c2

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
55

66
## [Unreleased]
77
### Added
8-
- Post modified line exec command ([#888](https://github.com/MitMaro/git-interactive-rebase-tool/pull/888))
8+
- Post modified line exec command ([#888](https://github.com/MitMaro/git-interactive-rebase-tool/pull/890))
99

10+
### Fixed
11+
- Flicker when action width changes ([#888](https://github.com/MitMaro/git-interactive-rebase-tool/pull/891))
1012

1113
## [2.3.0] - 2023-07-19
1214
### Added

src/core/src/modules/list/tests/render.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn noop_list() {
125125
Style view_data,
126126
"{TITLE}{HELP}",
127127
"{BODY}",
128-
"{Selected}{Normal} > noop {Pad( )}"
128+
"{Selected}{Normal} > noop {Pad( )}"
129129
);
130130
});
131131
}
@@ -171,3 +171,17 @@ fn pinned_segments() {
171171
},
172172
);
173173
}
174+
175+
#[test]
176+
fn full_with_short_actions() {
177+
module_test(&["pick aaaaaaaa comment 1"], &[], |mut test_context| {
178+
let mut module = create_list(&Config::new(), test_context.take_todo_file());
179+
let view_data = test_context.build_view_data(&mut module);
180+
assert_rendered_output!(
181+
Style view_data,
182+
"{TITLE}{HELP}",
183+
"{BODY}",
184+
"{Selected}{Normal} > {ActionPick}pick {Normal}aaaaaaaa comment 1{Pad( )}"
185+
);
186+
});
187+
}

src/core/src/modules/list/utils.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,14 @@ pub(super) fn get_todo_line_segments(
268268
false,
269269
));
270270

271+
let action_padding = cmp::max(maximum_action_width, 6);
272+
271273
let action_name = if is_full_width {
272274
if let Some(opt) = line.option() {
273-
format!("{:maximum_action_width$} ", format!("{action} {opt}"))
275+
format!("{:action_padding$} ", format!("{action} {opt}"))
274276
}
275277
else {
276-
format!("{:maximum_action_width$} ", action.to_string())
278+
format!("{:action_padding$} ", action.to_string())
277279
}
278280
}
279281
else {

0 commit comments

Comments
 (0)