Skip to content

fix - stale code block height during incremental chat layout#343

Merged
jdneo merged 3 commits into
mainfrom
tori/codeblock
Jul 9, 2026
Merged

fix - stale code block height during incremental chat layout#343
jdneo merged 3 commits into
mainfrom
tori/codeblock

Conversation

@xinyi-gong

Copy link
Copy Markdown
Member

Summary

  • Add a computeSize(...) override for SourceViewerComposite so code block height is measured synchronously from the current StyledText content.
  • Reuse a shared height helper in both measurement and async bounds refresh to keep scrollbar-height handling consistent.
  • Prevent incremental chat layout from caching stale code block heights while large code blocks are still waiting for async setBounds(...).

Copilot AI review requested due to automatic review settings July 8, 2026 09:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves chat code-block layout stability by ensuring SourceViewerComposite reports an up-to-date height synchronously (via computeSize(...)), reducing the chance that incremental chat layout caches stale code-block heights while async setBounds(...) is pending.

Changes:

  • Override computeSize(...) in SourceViewerComposite to measure height directly from the current StyledText content.
  • Factor out a shared getSourceViewerHeight(...) helper and reuse it in refreshScrollerLayout() for consistent scrollbar-height handling.

@jdneo

jdneo commented Jul 9, 2026

Copy link
Copy Markdown
Member

One small issue I observed:
image

When tab through the chat view, the highlighted blue line is missing at the bottom of each code block

@xinyi-gong

Copy link
Copy Markdown
Member Author

One small issue I observed: image

When tab through the chat view, the highlighted blue line is missing at the bottom of each code block

The issue was caused by the new computeSize(...) returning the inner StyledText content height directly, while SourceViewerComposite itself is created with SWT.BORDER. That meant the parent layout did not reserve the outer trim/border space, so the bottom focus border could be clipped.

I updated the sizing logic to convert the measured StyledText client size through computeTrim(...) before returning it from SourceViewerComposite.computeSize(...). This keeps the synchronous code block height measurement while preserving enough space for the composite border/focus outline.

@jdneo jdneo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jdneo jdneo merged commit 65db401 into main Jul 9, 2026
4 checks passed
@jdneo jdneo deleted the tori/codeblock branch July 9, 2026 06:08
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.

3 participants