message: Fix incremental rendering of the cell grid when multi-cell chars are involved
diff: * Copyright 2019 Simon Edwards <simon@simonzone.com>
  */
  -import { CharCellGrid } from "extraterm-char-cell-grid";
  +import { CharCellGrid, FLAG_MASK_WIDTH, FLAG_WIDTH_SHIFT, FLAG_MASK_EXTRA_FONT } from "extraterm-char-cell-grid";
  import { log, Logger, getLogger } from "extraterm-logging";
  import { ColorPatchCanvas } from "./ColorPatchCanvas";
  import { FontAtlas } from "./FontAtlas";
  @@ -421,9 +421,20 @@ export class CharRenderCanvas implements Disposable {
  const spaceCodePoint = " ".codePointAt(0);
  for (let j=0; j<height; j++) {
  +
  + // These control the correct re-rendering or not rendering
  + // of cells which are to the right of multi-cell characters.
  + let charWidthCounter = 0;
  + let renderedCharWidthCounter = 0;
  +
  for (let i=0; i<width; i++) {
  - const extraFontFlag = cellGrid.getExtraFontsFlag(i, j);
  - const renderedExtraFontFlag = renderedCellGrid.getExtraFontsFlag(i, j);
  +
  + const flags = cellGrid.getFlags(i, j);
  + const renderedFlags = renderedCellGrid.getFlags(i, j);
  +
  + const extraFontFlag = (flags & FLAG_MASK_EXTRA_FONT) !== 0;
  + const renderedExtraFontFlag = (renderedFlags & FLAG_MASK_EXTRA_FONT) !== 0;
  +
  if (extraFontFlag) {
  if ( ! renderedExtraFontFlag) {
  // Erase the char in the char canvas and make room for
  @@ -436,10 +447,32 @@ export class CharRenderCanvas implements Disposable {
  const style = cellGrid.getStyle(i, j);
  const renderedCodePoint = renderedCellGrid.getCodePoint(i, j);
  const renderedStyle = renderedCellGrid.getStyle(i, j);
  - if (codePoint !== renderedCodePoint || style !== renderedStyle) {
  +
  + const cellChanged = codePoint !== renderedCodePoint || style !== renderedStyle
  +
  + let mustRender = false;
  + if (cellChanged) {
  +
  + // Only allow the render if we aren't destroying an extra wide char to the left.
  + if (charWidthCounter <= 0) {
  + mustRender = true;
  + }
  + } else {
  + if(renderedCharWidthCounter > 0 && charWidthCounter <= 0) {
  + mustRender = true;
  + }
  + }
  + charWidthCounter = Math.max(charWidthCounter,
  + ((flags & FLAG_MASK_WIDTH) >> FLAG_WIDTH_SHIFT)+1);
  + renderedCharWidthCounter = Math.max(renderedCharWidthCounter,
  + ((renderedFlags & FLAG_MASK_WIDTH) >> FLAG_WIDTH_SHIFT)+1);
  + if (mustRender) {
  this._fontAtlas.drawCodePoint(ctx, codePoint, style, i * cellWidth, j * cellHeight);
  }
  }
  +
  + charWidthCounter--;
  + renderedCharWidthCounter--;
  }
  }
  }
  