histedit: fix diff colors stable
authorJordi Gutiérrez Hermoso <jordigh@octave.org>
Thu, 27 Oct 2022 17:34:02 -0400
branchstable
changeset 50302 22d7cb8174ef
parent 50301 9fc0d244a753
child 50303 0d3690f8ce2a
histedit: fix diff colors The problem here is that indexing a bytestring gives you integers, not chars, so the comparison to b'+' ends up being wrong. We don't really have a way to test curses output, so no tests to verify the correctness of this behaviour.
hgext/histedit.py
--- a/hgext/histedit.py	Wed Mar 15 05:49:56 2023 +0100
+++ b/hgext/histedit.py	Thu Oct 27 17:34:02 2022 -0400
@@ -1427,11 +1427,11 @@
         for y in range(0, length):
             line = output[y]
             if diffcolors:
-                if line and line[0] == b'+':
+                if line.startswith(b'+'):
                     win.addstr(
                         y, 0, line, curses.color_pair(COLOR_DIFF_ADD_LINE)
                     )
-                elif line and line[0] == b'-':
+                elif line.startswith(b'-'):
                     win.addstr(
                         y, 0, line, curses.color_pair(COLOR_DIFF_DEL_LINE)
                     )