Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 10, 2025

Description

Deleted cell decorators in notebook diff view caused UI flicker during scrolling due to incorrect whitespace position calculations when multiple view zones existed at the same position.

Root Cause

The NotebookCellsLayout whitespace management had three related bugs:

  • getWhitespacePosition: For non-zero positions, didn't account for other whitespaces at the same position with lower priority numbers, causing incorrect position calculations for deleted cell decorators
  • insertWhitespace: Updated prefix sum with only the new whitespace size instead of all whitespaces at that position
  • changeOneWhitespace: Didn't recalculate prefix sum with all remaining/new whitespaces when moving zones

Changes Made

Fixed whitespace position calculation:

// Before: Only handled priority ordering for afterPosition === 0
getWhitespacePosition(id: string): number {
  // ...
  return previousItemPosition + previousItemSize + whitespaceBeforeFirstItem + this.paddingTop;
}

// After: Handles priority ordering for all positions
getWhitespacePosition(id: string): number {
  // ...
  const whitespacesAtSamePosition = this._whitespace.filter(
    ws => ws.afterPosition === afterPosition && ws.priority < whitespace.priority
  );
  const whitespacesAtSamePositionSize = whitespacesAtSamePosition.reduce((acc, ws) => acc + ws.size, 0);
  return previousItemPosition + previousItemSize + whitespaceBeforeFirstItem + this.paddingTop + whitespacesAtSamePositionSize;
}

Fixed prefix sum updates in insertWhitespace and changeOneWhitespace:

// Before: Only included new whitespace
const accSize = itemSize + size;

// After: Includes all whitespaces at position
const allWhitespacesAtPosition = this._whitespace.filter(ws => ws.afterPosition === afterPosition);
const accSize = itemSize + allWhitespacesAtPosition.reduce((acc, ws) => acc + ws.size, 0);

Testing

Added test case validating multiple view zones at the same non-zero position with correct positioning based on priority ordering.

Original prompt

This section details on the original issue you should resolve

<issue_title>UI flicker when scrolling notebook with deleted lines in notebook diff</issue_title>
<issue_description>The decorators for deleted cells are not taken into account when computing height of cells for scrolling of notebooks.

</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix UI flicker when scrolling notebook with deleted lines Fix UI flicker when scrolling notebook diff with deleted cells Dec 10, 2025
Copilot AI requested a review from DonJayamanne December 10, 2025 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI flicker when scrolling notebook with deleted lines in notebook diff

2 participants