Mercurial > hg
comparison mercurial/crecord.py @ 27914:505a10b504ed stable
crecord: edit during hg crecord should preserve cursor position (issue5041)
This patch adds a variable to keep track of what hunk was selected
before the edit. We use that variable to select the hunk or its
replacement after the edit.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Wed, 20 Jan 2016 11:21:13 -0800 |
parents | a801d331a022 |
children | fedd81659643 |
comparison
equal
deleted
inserted
replaced
27913:91ac8cb79125 | 27914:505a10b504ed |
---|---|
1549 if isinstance(item, uihunkline): | 1549 if isinstance(item, uihunkline): |
1550 item = item.parentitem() | 1550 item = item.parentitem() |
1551 if not isinstance(item, uihunk): | 1551 if not isinstance(item, uihunk): |
1552 return | 1552 return |
1553 | 1553 |
1554 # To go back to that hunk or its replacement at the end of the edit | |
1555 itemindex = item.parentitem().hunks.index(item) | |
1556 | |
1554 beforeadded, beforeremoved = item.added, item.removed | 1557 beforeadded, beforeremoved = item.added, item.removed |
1555 newpatches = editpatchwitheditor(self, item) | 1558 newpatches = editpatchwitheditor(self, item) |
1556 if newpatches is None: | 1559 if newpatches is None: |
1557 if not test: | 1560 if not test: |
1558 updateui(self) | 1561 updateui(self) |
1573 h.folded = False | 1576 h.folded = False |
1574 header.hunks = hunksbefore + newhunks + hunksafter | 1577 header.hunks = hunksbefore + newhunks + hunksafter |
1575 if self.emptypatch(): | 1578 if self.emptypatch(): |
1576 header.hunks = hunksbefore + [item] + hunksafter | 1579 header.hunks = hunksbefore + [item] + hunksafter |
1577 self.currentselecteditem = header | 1580 self.currentselecteditem = header |
1581 if len(header.hunks) > itemindex: | |
1582 self.currentselecteditem = header.hunks[itemindex] | |
1578 | 1583 |
1579 if not test: | 1584 if not test: |
1580 updateui(self) | 1585 updateui(self) |
1581 | 1586 |
1582 def emptypatch(self): | 1587 def emptypatch(self): |