Fix off-by-one errors in syntax highlighting (#14780)

In the case that a line ended with a 0-length run, we would get our
highlights offset by one position.

Release Notes:

- Fixed syntax highlights being offset from syntax in diagnostics
popovers.
This commit is contained in:
Conrad Irwin 2024-07-18 22:37:30 -06:00 committed by GitHub
parent be45f32753
commit 87457f9ae8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 7 deletions

View file

@ -15,6 +15,15 @@ const MARKDOWN_EXAMPLE: &'static str = r#"
## Headings
Headings are created by adding one or more `#` symbols before your heading text. The number of `#` you use will determine the size of the heading.
```rust
gpui::window::ViewContext
impl<'a, V> ViewContext<'a, V>
pub fn on_blur(&mut self, handle: &FocusHandle, listener: impl FnMut(&mut V, &mut iewContext<V>) + 'static) -> Subscription
where
// Bounds from impl:
V: 'static,
```
## Emphasis
Emphasis can be added with italics or bold. *This text will be italic*. _This will also be italic_
@ -94,12 +103,13 @@ pub fn main() {
cx.bind_keys([KeyBinding::new("cmd-c", markdown::Copy, None)]);
let node_runtime = FakeNodeRuntime::new();
let language_registry = Arc::new(LanguageRegistry::new(
Task::ready(()),
cx.background_executor().clone(),
));
languages::init(language_registry.clone(), node_runtime, cx);
theme::init(LoadThemes::JustBase, cx);
let language_registry =
LanguageRegistry::new(Task::ready(()), cx.background_executor().clone());
language_registry.set_theme(cx.theme().clone());
let language_registry = Arc::new(language_registry);
languages::init(language_registry.clone(), node_runtime, cx);
Assets.load_fonts(cx).unwrap();
cx.activate(true);