From 7af277f683cd5ee0d5e3ffbc1dd3ce1d61f17848 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Fri, 29 Jul 2016 13:29:14 +0100 Subject: Auto-highlight conflict when rich_text is called --- lib/gitlab/diff/line.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/gitlab/diff') diff --git a/lib/gitlab/diff/line.rb b/lib/gitlab/diff/line.rb index 5196051f90d..38400b48b5c 100644 --- a/lib/gitlab/diff/line.rb +++ b/lib/gitlab/diff/line.rb @@ -2,12 +2,13 @@ module Gitlab module Diff class Line attr_reader :type, :index, :old_pos, :new_pos + attr_writer :rich_text attr_accessor :text - attr_accessor :rich_text - def initialize(text, type, index, old_pos, new_pos) + def initialize(text, type, index, old_pos, new_pos, parent: nil) @text, @type, @index = text, type, index @old_pos, @new_pos = old_pos, new_pos + @parent = parent end def self.init_from_hash(hash) @@ -44,6 +45,12 @@ module Gitlab type == 'old' end + def rich_text + @parent.highlight_lines! if @parent && !@rich_text + + @rich_text + end + def meta? type == 'match' || type == 'nonewline' end -- cgit v1.2.3