Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

fix: Fixes incorrect highlighting for comments at the start of a file#64235

Merged
varungandhi-src merged 3 commits into
mainfrom
vg/off-by-one
Aug 5, 2024
Merged

fix: Fixes incorrect highlighting for comments at the start of a file#64235
varungandhi-src merged 3 commits into
mainfrom
vg/off-by-one

Conversation

@varungandhi-src

Copy link
Copy Markdown
Contributor

The PR is already small but is broken up into tiny commits - the main change is shown
in the second commit. The problem was that we were incorrectly not doing a "stack push"
operation when encountering a comment, but we were doing a pop which triggered
a change in the source range for the next source range (this is done to avoid overlap
between the current occurrence and the subsequent occurrence that will be emitted).

This is fixed by not ignoring comment markers. As a consequence, we will emit
a few more occurrences than earlier, but I don't think it should be a big problem
in practice. We can also fuse these if needed.

Fixes https://github.com/sourcegraph/sourcegraph/issues/60852

Test plan

Added snapshot tests

Changelog

Fixes incorrect syntax highlighting when a comment is present at the start of a file.

@cla-bot cla-bot Bot added the cla-signed label Aug 2, 2024
@github-actions github-actions Bot added team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) team/product-platform labels Aug 2, 2024

@antonsviridov-src antonsviridov-src 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.

Nice!

@varungandhi-src varungandhi-src merged commit e5fdb5c into main Aug 5, 2024
@varungandhi-src varungandhi-src deleted the vg/off-by-one branch August 5, 2024 12:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed team/graph Graph Team (previously Code Intel/Language Tools/Language Platform) team/product-platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Off-by-one error in highlighting when comment is at start of file

2 participants