Skip to content

Commit

Permalink
diff: support line numbers for unmerged conflict files
Browse files Browse the repository at this point in the history
Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed Feb 19, 2017
1 parent f43fc47 commit f5c79e8
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions cola/widgets/diff.py
Expand Up @@ -209,12 +209,19 @@ def width_hint(self):
if not self.isVisible():
return 0
parser = self.parser

if parser.merge:
columns = 3
extra = 3 # one space in-between, one space after
else:
columns = 2
extra = 2 # one space in-between, one space after

if parser.valid:
digits = parser.digits() * 2
digits = parser.digits() * columns
else:
digits = 4

extra = 2 # one space in-between, one space after
return defs.margin + (self._char_width * (digits + extra))

def set_highlighted(self, line_number):
Expand Down Expand Up @@ -265,8 +272,13 @@ def paintEvent(self, event):
painter.fillRect(rect.x(), rect.y(),
width, rect.height(), window)

a, b = lines[block_number]
text = fmt.value(a, b)
line = lines[block_number]
if len(line) == 2:
a, b = line
text = fmt.value(a, b)
elif len(line) == 3:
old, base, new = line
text = fmt.merge_value(old, base, new)

painter.drawText(rect.x(), rect.y(),
self.width() - (defs.margin * 2), rect.height(),
Expand Down

0 comments on commit f5c79e8

Please sign in to comment.