Skip to content

Conversation

Copy link

Copilot AI commented Jan 23, 2026

When navigating to the playground with ?example=math, syntax highlighting wasn't applied and results showed stale values until manual edit.

Root Cause

In app.js, loadExampleFromUrl() was called before onDidChangeContent handlers were registered. When setValue() was called on the models, no handlers existed to trigger highlighting or evaluation.

Changes

  • Reordered initialization in app.js: register event handlers before calling loadExampleFromUrl()
// Before: handlers registered after example load (broken)
applyHighlighting();
evaluate();
loadExampleFromUrl();  // setValue() triggers nothing
expressionModel.onDidChangeContent(...);  // too late

// After: handlers registered first (fixed)
expressionModel.onDidChangeContent(...);
applyHighlighting();
evaluate();
loadExampleFromUrl();  // setValue() now triggers handlers
Original prompt

When navigation to an example with the "example" query parameter, ensure the example is evaluated and the expression is syntax-hightlighted. Right now, no syntax hightlighting in the monaco editor is visible and the result always shows "100" until an edit is made in the expression monaco editor


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…query parameter

Co-authored-by: Sander-Toonen <5106372+Sander-Toonen@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix syntax highlighting for evaluated example Fix example loading from URL query parameter Jan 23, 2026
Copilot AI requested a review from Sander-Toonen January 23, 2026 15:59
@Sander-Toonen Sander-Toonen marked this pull request as ready for review January 23, 2026 16:02
Copilot AI review requested due to automatic review settings January 23, 2026 16:02
Copy link

Copilot AI left a comment

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 fixes the playground behavior when loading an example via the ?example= URL query parameter so that syntax highlighting and evaluation occur immediately without requiring a manual edit.

Changes:

  • Reordered initialization to register onDidChangeContent handlers on expressionModel and contextModel before performing any initial highlighting/evaluation.
  • Moved the loadExampleFromUrl() call to occur after event handlers are set up so that setValue() correctly triggers highlighting and evaluation.
  • Kept an explicit initial applyHighlighting() and evaluate() call to handle the default content load path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Sander-Toonen Sander-Toonen merged commit 5cd7549 into master Jan 23, 2026
10 checks passed
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.

2 participants