Fix intraline highlights
Highlight with dark color if no intraline info, and use light color if we do have intraline info but no changes. Change-Id: Ied6a33b60792c4b0dbf1dc3c17020ee10aa2910a
This commit is contained in:
		@@ -332,8 +332,11 @@
 | 
			
		||||
    if (line.type !== GrDiffLine.Type.BLANK) {
 | 
			
		||||
      td.classList.add('content');
 | 
			
		||||
    }
 | 
			
		||||
    if (line.highlights.length === 0) {
 | 
			
		||||
      td.classList.add('no-highlights');
 | 
			
		||||
 | 
			
		||||
    // If intraline info is not available, the entire line will be
 | 
			
		||||
    // considered as changed and marked as dark red / green color
 | 
			
		||||
    if (!line.hasIntralineInfo) {
 | 
			
		||||
      td.classList.add('no-intraline-info');
 | 
			
		||||
    }
 | 
			
		||||
    td.classList.add(line.type);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -437,7 +437,10 @@
 | 
			
		||||
      if (type !== GrDiffLine.Type.ADD) line.beforeNumber = offsetLeft + i;
 | 
			
		||||
      if (type !== GrDiffLine.Type.REMOVE) line.afterNumber = offsetRight + i;
 | 
			
		||||
      if (opt_highlights) {
 | 
			
		||||
        line.hasIntralineInfo = true;
 | 
			
		||||
        line.highlights = opt_highlights.filter(hl => hl.contentIndex === i);
 | 
			
		||||
      } else {
 | 
			
		||||
        line.hasIntralineInfo = false;
 | 
			
		||||
      }
 | 
			
		||||
      return line;
 | 
			
		||||
    },
 | 
			
		||||
 
 | 
			
		||||
@@ -30,9 +30,14 @@
 | 
			
		||||
 | 
			
		||||
    /** @type {number|string} */
 | 
			
		||||
    this.beforeNumber = opt_beforeLine || 0;
 | 
			
		||||
 | 
			
		||||
    /** @type {number|string} */
 | 
			
		||||
    this.afterNumber = opt_afterLine || 0;
 | 
			
		||||
 | 
			
		||||
    /** @type {boolean} */
 | 
			
		||||
    this.hasIntralineInfo = false;
 | 
			
		||||
 | 
			
		||||
    /** @type Array<GrDiffLine.Highlights> */
 | 
			
		||||
    this.highlights = [];
 | 
			
		||||
 | 
			
		||||
    /** @type {?Array<Object>} ?Array<!GrDiffGroup> */
 | 
			
		||||
 
 | 
			
		||||
@@ -131,8 +131,8 @@ limitations under the License.
 | 
			
		||||
        width: var(--content-width, 80ch);
 | 
			
		||||
      }
 | 
			
		||||
      .content.add .intraline,
 | 
			
		||||
      /* If there are no intraline changes, consider everything changed */
 | 
			
		||||
      .content.add.no-highlights,
 | 
			
		||||
      /* If there are no intraline info, consider everything changed */
 | 
			
		||||
      .content.add.no-intraline-info,
 | 
			
		||||
      .delta.total .content.add {
 | 
			
		||||
        background-color: var(--dark-add-highlight-color);
 | 
			
		||||
      }
 | 
			
		||||
@@ -140,8 +140,8 @@ limitations under the License.
 | 
			
		||||
        background-color: var(--light-add-highlight-color);
 | 
			
		||||
      }
 | 
			
		||||
      .content.remove .intraline,
 | 
			
		||||
      /* If there are no intraline changes, consider everything changed */
 | 
			
		||||
      .content.remove.no-highlights,
 | 
			
		||||
      /* If there are no intraline info, consider everything changed */
 | 
			
		||||
      .content.remove.no-intraline-info,
 | 
			
		||||
      .delta.total .content.remove {
 | 
			
		||||
        background-color: var(--dark-remove-highlight-color);
 | 
			
		||||
      }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user