Skip to content

Fix REPL highlighting for ';'-separated statements - #141

Merged
Mike Krüger (mkrueger) merged 3 commits into
mainfrom
dev/mkrueger/fix-highlight-semicolon
Jun 25, 2026
Merged

Mike Krüger (mkrueger) merged 3 commits into
mainfrom
dev/mkrueger/fix-highlight-semicolon

Conversation

@mkrueger

@mkrueger Mike Krüger (mkrueger) commented Jun 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes REPL syntax highlighting for multi-statement input separated by ;.

Problem

The highlighter built its markup from StatementParser.ParseStatement() (singular), which parses only the first statement and stops at the ; command terminator. Everything after the ; was never visited and fell through to the "append remaining text" path as uncolored plain text. The REPL executor itself uses ParseStatements() (plural), so highlighting was inconsistent with execution.

Example: echo "foobar" ; echo "foobar" — only the first echo was highlighted.

image

Changes

  • BuildHighlightedMarkup now parses with ParseStatements() and visits every statement with a single shared HighlightingVisitor. Because the visitor uses absolute token positions and fills gaps as plain text, each statement is highlighted correctly.
  • The cached AST field changed from Statement? to List<Statement>? (caching still only happens on a clean parse).
  • The ; command separators are now colored using the operator color. Separator positions are collected by lexing the input (Lexer.Tokenize()), so ; inside string literals is left untouched.

Tests

  • Added SemicolonSeparatedStatements_HighlightEveryCommand: asserts echo "foobar" ; echo "foobar" round-trips, both echo commands get identical command styling, and the ; is its own non-default-colored operator segment.
  • All highlighter tests pass (18/18); build is clean (0 warnings).

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 pull request fixes REPL syntax highlighting for multi-statement input separated by ;, aligning highlighting behavior with the REPL executor by parsing and visiting all statements instead of only the first.

Changes:

  • Switch highlighting from ParseStatement() to ParseStatements() and visit each statement with a shared HighlightingVisitor.
  • Cache a list of parsed statements (List<Statement>?) instead of a single statement for prefix-based reuse.
  • Color real ; separators as operators by collecting separator positions via lexing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ShellInterpreter.Highlighter.cs Updates the highlighter to parse/visit multiple statements and adds separator-aware plain-text rendering for operator-colored ;.
CosmosDBShell.Tests/Shell/HighlighterIncompleteProbeTests.cs Adds a regression test ensuring both commands and the ; separator are highlighted correctly for semicolon-separated input.
@github-code-quality

github-code-quality Bot commented Jun 24, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall coverage in the dev/mkrueger/fix-hig... branch remains at 63%, unchanged from the main branch.

Show a code coverage summary of the most impacted files.
File main ac139bc dev/mkrueger/fix-hig... fff0ee0 +/-
D:\a\CosmosDBSh....Highlighter.cs 79% 80% +1%
D:\a\CosmosDBSh...Parser\Lexer.cs 92% 93% +1%

Updated June 25, 2026 08:58 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

Copilot AI review requested due to automatic review settings June 24, 2026 11:45
@mkrueger
Mike Krüger (mkrueger) force-pushed the dev/mkrueger/fix-highlight-semicolon branch from 00869b9 to c64c98e Compare June 24, 2026 11:45

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Parse multiple statements with ParseStatements() so every command in a
';'-separated line is highlighted, and color ';' with the redirection
color so separators stand out from operators, strings, and variables.

- Collect semicolon token positions and emit FormatRedirection in the
  highlighter's plain-text gap filler
- Cache multiple statements; ordinal prefix match for incremental highlight
- Tests for multi-statement highlighting
Copilot AI review requested due to automatic review settings June 24, 2026 12:09
@mkrueger
Mike Krüger (mkrueger) force-pushed the dev/mkrueger/fix-highlight-semicolon branch from 3de2127 to 33f3a9f Compare June 24, 2026 12:09

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings June 25, 2026 08:54

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@mkrueger
Mike Krüger (mkrueger) merged commit 32c1859 into main Jun 25, 2026
10 checks passed
@mkrueger
Mike Krüger (mkrueger) deleted the dev/mkrueger/fix-highlight-semicolon branch June 25, 2026 09:30
Mike Krüger (mkrueger) added a commit that referenced this pull request Jun 25, 2026
## Summary

Stamps the `Unreleased` changelog section with the concrete release
version for the next preview drop.

## Change

- `## Unreleased` → `## 1.1.100-preview — 2026-06-25`

## Versioning rationale

The version is driven by Nerdbank.GitVersioning (`version.json` =
`1.1-preview`, patch = git height). `main` currently sits at
`1.1.99-preview` (after #141 merged). Because this changelog commit adds
one commit on top of `main`, the build stamped from the release commit
will be `1.1.100-preview`, which is what the heading now reflects.

> Note: the exact patch is git-height dependent. If extra commits land
before the release is tagged, re-confirm with `dotnet nbgv get-version`
and bump the heading accordingly.
Mike Krüger (mkrueger) added a commit that referenced this pull request Jul 1, 2026
….4 (#143)

## Summary

Rewrites the `1.1.114-preview` changelog section so it accurately
documents **all** changes merged since `1.1.4-preview`, not just the
server-side programming commands and two breaking changes.

PR #142 only stamped the release heading. This fills in the body.

## What changed

The `1.1.114-preview` entry now covers every PR merged on top of 1.1.4:

- **Highlights** of the major additions.
- **New features**: `theme` (#83), `filter` (#67), `watch`/`tail`
(#115), `edit` (#117), `index` (#116), `throughput` (#130),
`import`/`export` (#95), `sproc`/`udf`/`trigger` (#124), `--diagnostics`
(#127), `--otel` (#126).
- **Improvements**: incomplete-construct highlighting (#93),
theme-routed colors and JSON token highlighting (#97), source-caret
diagnostics (#99), refreshed prompt (#133), `ls` summaries (#129, #139).
- **Security**: MCP hardening (#120), CodeQL alerts in connect flow
(#132).
- **Fixes**: `;`-separator REPL highlighting (#141).
- **Breaking changes** (unchanged): `indexpolicy` removed/aliased to
`index` (#140); `theme edit --editor` removed.
- **Documentation** (#123) and **Build & pipeline** (#128, #121).

Items already shipped in 1.1.4 are not re-listed.

## Validation

- Documentation-only change; descriptions verified against
`docs/commands.md` and `docs/navigation.md`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants