CodeMirror Blob: fix syntax highlighting error
Created by: olafurpg
Previously, syntax highlighting occasionally failed because the
occurrences were not correctly ordered when we computed CodeMirror
"decorations", causing RangeSetBuilder.finish()
to crash with an
uncaught exception. This commit addresses the issue with several fixes:
- Sort occurrences on the client-side so that it's OK if the server returns unordered occurrences
- Use the higher-level
Occurrences
class to minimize the risk of making mistakes when working with the low-levelrange: number[]
encoding. - Catch exceptions and log a helpful error message if an error gets thrown again while computing decorations, making it easier to troubleshoot similar issues in the future.
Fixes #40352 (closed) Fixes #40355 (closed)
Test plan
Run sg start
and browse Java and TypeScript files. All files should render
correct highlighting, including backend.ts
and client/jetbrains/src/main/java/com/sourcegraph/config/ThemeUtil.java
(which don't render correctly currently on sourcegraph.com)
App preview:
Check out the client app preview documentation to learn more.