helix-mirror/helix-core
Michael Davis 22c1a40725
Fix finding injection layer in tree cursor with nested layers (#11365)
The `take_while` should limit the layers to those that can match the
input range so we don't always scan the entire `injection_layers`. We
can limit `depth == 1` layers to those that start before the search
`end`. Deeper layers overlap with shallower layers though so we need
to allow those layers as well in the `take_while`.

For example

```vue
<script setup lang="ts">
const foo = 'bar'.match(/foo/);
const bar = foo;
</script>
```

L2 and L3 are a typescript layer and the `/foo/` part is a small regex
layer. If you used `A-o` before the regex layer you would select the
entire typescript layer. The search in `layer_id_containing_byte_range`
would not consider the typescript layer since the regex layer comes
earlier in `injection_ranges` and that layer's start is after `end`.
The regex layer has a depth of `2` though so the change in this commit
allows scanning through that layer.

Co-authored-by: Pascal Kuthe <pascalkuthe@pm.me>
2024-07-31 05:29:31 +09:00
..
src Fix finding injection layer in tree cursor with nested layers (#11365) 2024-07-31 05:29:31 +09:00
tests Resolve new Clippy lints 2024-05-07 15:15:52 -04:00
.gitignore Initial import. 2020-05-20 18:14:51 +09:00
Cargo.toml build(deps): bump the rust-dependencies group with 6 updates (#11371) 2024-07-29 21:10:47 -05:00