Mercurial > hg
changeset 51627:6ec4c745c598 stable
chistedit: change action for the correct item
We have an experimental config histedit.later-commits-first from c820866c52f9,
and when it's true, the order of commits in histedit UI is reversed, both in
text mode and in curses mode.
But before this patch key presses in curses mode would change histedit actions
in the same old order, i.e. trying to edit the latest commit (which would be
first now) would put "edit" action on the last commit in the list. This wasn't
a cosmetic issue, histedit would actually proceed to edit the first commit in
the list.
Let's map rules to display items (hopefully now correctly).
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Tue, 07 May 2024 15:15:41 +0400 |
parents | 99072b02138f |
children | eb11153c1698 |
files | hgext/histedit.py |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/histedit.py Mon May 06 18:48:37 2024 +0200 +++ b/hgext/histedit.py Tue May 07 15:15:41 2024 +0400 @@ -1581,14 +1581,16 @@ def change_action(self, pos, action): """Change the action state on the given position to the new action""" - assert 0 <= pos < len(self.rules) - self.rules[pos].action = action + rule_pos = self.display_pos_to_rule_pos(pos) + assert 0 <= rule_pos < len(self.rules) + self.rules[rule_pos].action = action def cycle_action(self, pos, next=False): """Changes the action state the next or the previous action from the action list""" - assert 0 <= pos < len(self.rules) - current = self.rules[pos].action + rule_pos = self.display_pos_to_rule_pos(pos) + assert 0 <= rule_pos < len(self.rules) + current = self.rules[rule_pos].action assert current in KEY_LIST @@ -1597,6 +1599,8 @@ index += 1 else: index -= 1 + # using pos instead of rule_pos because change_action() also calls + # display_pos_to_rule_pos() self.change_action(pos, KEY_LIST[index % len(KEY_LIST)]) def change_view(self, delta, unit):