Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Byte range does not align with char boundaries: range 715..719' #3283

Closed
myisaak opened this issue Aug 1, 2022 · 4 comments · Fixed by #7621
Closed

Byte range does not align with char boundaries: range 715..719' #3283

myisaak opened this issue Aug 1, 2022 · 4 comments · Fixed by #7621
Labels
A-tree-sitter Area: Tree-sitter C-bug Category: This is a bug

Comments

@myisaak
Copy link

myisaak commented Aug 1, 2022

Summary

When opening a specific file in svelte, adding a new line, then deleting it Helix panics.

<script lang="ts">
    // try to delete anything here (before the emoticon)
    // 👆 false parameter is required for svelte https://github.com/saadeghi/theme-change
</script>⏎ 
thread 'main' panicked at 'byte_slice(): Byte range does not align with char boundaries: range 709..713', /home/stromae/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/ropey-1.5.0/src/slice.rs:692:23
stack backtrace:
   0: rust_begin_unwind
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
   2: ropey::slice::RopeSlice::byte_slice
   3: <helix_core::syntax::RopeProvider as tree_sitter::TextProvider>::text
   4: tree_sitter::QueryMatch::satisfies_text_predicates
   5: <tree_sitter::QueryCaptures<T> as core::iter::traits::iterator::Iterator>::next
   6: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
   7: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
   8: helix_core::syntax::Syntax::highlight_iter
   9: helix_term::ui::editor::EditorView::doc_syntax_highlights
  10: helix_term::ui::editor::EditorView::render_view
  11: <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::render
  12: helix_term::compositor::Compositor::render
  13: helix_term::application::Application::handle_terminal_events
  14: helix_term::application::Application::event_loop_until_idle::{{closure}}
  15: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  16: std::thread::local::LocalKey<T>::with
  17: tokio::park::thread::CachedParkThread::block_on
  18: tokio::runtime::thread_pool::ThreadPool::block_on
  19: tokio::runtime::Runtime::block_on
  20: hx::main

Reproduction Steps

t-rec_2

Helix log

~/.cache/helix/helix.log
2022-08-01T18:20:10.351 helix_lsp::transport [ERROR] err <- "  start: { line: 27, column: 4, character: 750 },\n"
2022-08-01T18:20:10.351 helix_lsp::transport [ERROR] err <- "  end: { line: 27, column: 4, character: 750 },\n"
2022-08-01T18:20:10.351 helix_lsp::transport [ERROR] err <- "  pos: 750,\n"
2022-08-01T18:20:10.351 helix_lsp::transport [ERROR] err <- "  filename: '/home/stromae/Projects/webapp/evita/dashboard/src/routes/__layout.svelte',\n"
2022-08-01T18:20:10.351 helix_lsp::transport [ERROR] err <- "  frame: '25:       </Sidebar>\\n' +\n"
2022-08-01T18:20:10.351 helix_lsp::transport [ERROR] err <- "    '26:     </div>\\n' +\n"
2022-08-01T18:20:10.351 helix_lsp::transport [ERROR] err <- "    '27:   {/if}\\n' +\n"
2022-08-01T18:20:10.351 helix_lsp::transport [ERROR] err <- "    '        ^\\n' +\n"
2022-08-01T18:20:10.351 helix_lsp::transport [ERROR] err <- "    '28: </Splashscreen>',\n"
2022-08-01T18:20:10.351 helix_lsp::transport [ERROR] err <- "  __source: 'Script'\n"
2022-08-01T18:20:10.351 helix_lsp::transport [ERROR] err <- "}\n"
2022-08-01T18:20:21.211 helix_lsp::transport [ERROR] err <- "Using Svelte v3.48.0 from /home/stromae/Projects/webapp/evita/dashboard/node_modules/svelte/compiler\n"
2022-08-01T18:20:21.402 helix_lsp::transport [ERROR] err <- "Using Svelte v3.48.0 from /home/stromae/Projects/webapp/evita/dashboard/node_modules/svelte/compiler\n"
2022-08-01T18:20:52.456 helix_term::application [WARN] failed to load theme `monokai_pro_maschine` - No such file or directory (os error 2)
2022-08-01T18:20:56.428 helix_lsp::transport [ERROR] err <- "Initialize language server at  file:///home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:20:56.512 helix_lsp::transport [ERROR] err <- "Initialize new ts service at  /home/stromae/Projects/webapp/evita/dashboard/jsconfig.json\n"
2022-08-01T18:20:56.554 helix_lsp::transport [ERROR] err <- "Trying to load configs for /home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:20:56.670 helix_lsp::transport [ERROR] err <- "Loaded config at  /home/stromae/Projects/webapp/evita/dashboard/svelte.config.js\n"
2022-08-01T18:20:56.740 helix_lsp::transport [ERROR] err <- "SnapshotManager File Statistics:\n"
2022-08-01T18:20:56.740 helix_lsp::transport [ERROR] err <- "Project files: 105\n"
2022-08-01T18:20:56.740 helix_lsp::transport [ERROR] err <- "Svelte files: 61\n"
2022-08-01T18:20:56.740 helix_lsp::transport [ERROR] err <- "From node_modules: 0\n"
2022-08-01T18:20:56.740 helix_lsp::transport [ERROR] err <- "Total: 105\n"
2022-08-01T18:20:57.373 helix_lsp::transport [ERROR] err <- "Using Svelte v3.48.0 from /home/stromae/Projects/webapp/evita/dashboard/node_modules/svelte/compiler\n"
2022-08-01T18:22:47.238 helix_term::application [WARN] failed to load theme `monokai_pro_maschine` - No such file or directory (os error 2)
2022-08-01T18:22:50.533 helix_lsp::transport [ERROR] err <- "Initialize language server at  file:///home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:22:50.599 helix_lsp::transport [ERROR] err <- "Initialize new ts service at  /home/stromae/Projects/webapp/evita/dashboard/jsconfig.json\n"
2022-08-01T18:22:50.636 helix_lsp::transport [ERROR] err <- "Trying to load configs for /home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:22:50.702 helix_lsp::transport [ERROR] err <- "Loaded config at  /home/stromae/Projects/webapp/evita/dashboard/svelte.config.js\n"
2022-08-01T18:22:50.769 helix_lsp::transport [ERROR] err <- "SnapshotManager File Statistics:\n"
2022-08-01T18:22:50.769 helix_lsp::transport [ERROR] err <- "Project files: 105\n"
2022-08-01T18:22:50.769 helix_lsp::transport [ERROR] err <- "Svelte files: 61\n"
2022-08-01T18:22:50.769 helix_lsp::transport [ERROR] err <- "From node_modules: 0\n"
2022-08-01T18:22:50.769 helix_lsp::transport [ERROR] err <- "Total: 105\n"
2022-08-01T18:22:51.426 helix_lsp::transport [ERROR] err <- "Using Svelte v3.48.0 from /home/stromae/Projects/webapp/evita/dashboard/node_modules/svelte/compiler\n"
2022-08-01T18:25:57.651 helix_term::application [WARN] failed to load theme `monokai_pro_maschine` - No such file or directory (os error 2)
2022-08-01T18:26:01.266 helix_lsp::transport [ERROR] err <- "Initialize language server at  file:///home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:26:01.333 helix_lsp::transport [ERROR] err <- "Initialize new ts service at  /home/stromae/Projects/webapp/evita/dashboard/jsconfig.json\n"
2022-08-01T18:26:01.370 helix_lsp::transport [ERROR] err <- "Trying to load configs for /home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:26:01.439 helix_lsp::transport [ERROR] err <- "Loaded config at  /home/stromae/Projects/webapp/evita/dashboard/svelte.config.js\n"
2022-08-01T18:26:01.507 helix_lsp::transport [ERROR] err <- "SnapshotManager File Statistics:\n"
2022-08-01T18:26:01.507 helix_lsp::transport [ERROR] err <- "Project files: 105\n"
2022-08-01T18:26:01.507 helix_lsp::transport [ERROR] err <- "Svelte files: 61\n"
2022-08-01T18:26:01.507 helix_lsp::transport [ERROR] err <- "From node_modules: 0\n"
2022-08-01T18:26:01.507 helix_lsp::transport [ERROR] err <- "Total: 105\n"
2022-08-01T18:26:02.162 helix_lsp::transport [ERROR] err <- "Using Svelte v3.48.0 from /home/stromae/Projects/webapp/evita/dashboard/node_modules/svelte/compiler\n"
2022-08-01T18:26:50.440 helix_term::application [WARN] failed to load theme `monokai_pro_maschine` - No such file or directory (os error 2)
2022-08-01T18:26:54.464 helix_lsp::transport [ERROR] err <- "Initialize language server at  file:///home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:26:54.534 helix_lsp::transport [ERROR] err <- "Initialize new ts service at  /home/stromae/Projects/webapp/evita/dashboard/jsconfig.json\n"
2022-08-01T18:26:54.573 helix_lsp::transport [ERROR] err <- "Trying to load configs for /home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:26:54.640 helix_lsp::transport [ERROR] err <- "Loaded config at  /home/stromae/Projects/webapp/evita/dashboard/svelte.config.js\n"
2022-08-01T18:26:54.714 helix_lsp::transport [ERROR] err <- "SnapshotManager File Statistics:\n"
2022-08-01T18:26:54.714 helix_lsp::transport [ERROR] err <- "Project files: 105\n"
2022-08-01T18:26:54.714 helix_lsp::transport [ERROR] err <- "Svelte files: 61\n"
2022-08-01T18:26:54.714 helix_lsp::transport [ERROR] err <- "From node_modules: 0\n"
2022-08-01T18:26:54.714 helix_lsp::transport [ERROR] err <- "Total: 105\n"
2022-08-01T18:26:55.366 helix_lsp::transport [ERROR] err <- "Using Svelte v3.48.0 from /home/stromae/Projects/webapp/evita/dashboard/node_modules/svelte/compiler\n"
2022-08-01T18:27:01.936 helix_term::application [WARN] failed to load theme `monokai_pro_maschine` - No such file or directory (os error 2)
2022-08-01T18:27:04.971 helix_lsp::transport [ERROR] err <- "Initialize language server at  file:///home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:27:05.039 helix_lsp::transport [ERROR] err <- "Initialize new ts service at  /home/stromae/Projects/webapp/evita/dashboard/jsconfig.json\n"
2022-08-01T18:27:05.076 helix_lsp::transport [ERROR] err <- "Trying to load configs for /home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:27:05.138 helix_lsp::transport [ERROR] err <- "Loaded config at  /home/stromae/Projects/webapp/evita/dashboard/svelte.config.js\n"
2022-08-01T18:27:05.203 helix_lsp::transport [ERROR] err <- "SnapshotManager File Statistics:\n"
2022-08-01T18:27:05.203 helix_lsp::transport [ERROR] err <- "Project files: 105\n"
2022-08-01T18:27:05.203 helix_lsp::transport [ERROR] err <- "Svelte files: 61\n"
2022-08-01T18:27:05.203 helix_lsp::transport [ERROR] err <- "From node_modules: 0\n"
2022-08-01T18:27:05.203 helix_lsp::transport [ERROR] err <- "Total: 105\n"
2022-08-01T18:27:05.866 helix_lsp::transport [ERROR] err <- "Using Svelte v3.48.0 from /home/stromae/Projects/webapp/evita/dashboard/node_modules/svelte/compiler\n"
2022-08-01T18:28:02.570 helix_term::application [WARN] failed to load theme `monokai_pro_maschine` - No such file or directory (os error 2)
2022-08-01T18:28:06.641 helix_lsp::transport [ERROR] err <- "Initialize language server at  file:///home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:28:06.705 helix_lsp::transport [ERROR] err <- "Initialize new ts service at  /home/stromae/Projects/webapp/evita/dashboard/jsconfig.json\n"
2022-08-01T18:28:06.741 helix_lsp::transport [ERROR] err <- "Trying to load configs for /home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:28:06.806 helix_lsp::transport [ERROR] err <- "Loaded config at  /home/stromae/Projects/webapp/evita/dashboard/svelte.config.js\n"
2022-08-01T18:28:06.871 helix_lsp::transport [ERROR] err <- "SnapshotManager File Statistics:\n"
2022-08-01T18:28:06.871 helix_lsp::transport [ERROR] err <- "Project files: 105\n"
2022-08-01T18:28:06.871 helix_lsp::transport [ERROR] err <- "Svelte files: 61\n"
2022-08-01T18:28:06.871 helix_lsp::transport [ERROR] err <- "From node_modules: 0\n"
2022-08-01T18:28:06.871 helix_lsp::transport [ERROR] err <- "Total: 105\n"
2022-08-01T18:28:11.627 helix_term::application [WARN] failed to load theme `monokai_pro_maschine` - No such file or directory (os error 2)
2022-08-01T18:28:16.608 helix_lsp::transport [ERROR] err <- "Initialize language server at  file:///home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:28:16.674 helix_lsp::transport [ERROR] err <- "Initialize new ts service at  /home/stromae/Projects/webapp/evita/dashboard/jsconfig.json\n"
2022-08-01T18:28:16.710 helix_lsp::transport [ERROR] err <- "Trying to load configs for /home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:28:16.780 helix_lsp::transport [ERROR] err <- "Loaded config at  /home/stromae/Projects/webapp/evita/dashboard/svelte.config.js\n"
2022-08-01T18:28:16.824 helix_lsp::transport [ERROR] err <- "SnapshotManager File Statistics:\n"
2022-08-01T18:28:16.824 helix_lsp::transport [ERROR] err <- "Project files: 105\n"
2022-08-01T18:28:16.824 helix_lsp::transport [ERROR] err <- "Svelte files: 61\n"
2022-08-01T18:28:16.824 helix_lsp::transport [ERROR] err <- "From node_modules: 0\n"
2022-08-01T18:28:16.824 helix_lsp::transport [ERROR] err <- "Total: 105\n"
2022-08-01T18:28:21.862 helix_term::application [ERROR] Timed out waiting for language servers to shutdown
2022-08-01T18:28:22.878 helix_term::application [WARN] failed to load theme `monokai_pro_maschine` - No such file or directory (os error 2)
2022-08-01T18:28:25.954 helix_lsp::transport [ERROR] err <- "Initialize language server at  file:///home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:28:26.024 helix_lsp::transport [ERROR] err <- "Initialize new ts service at  /home/stromae/Projects/webapp/evita/dashboard/jsconfig.json\n"
2022-08-01T18:28:26.064 helix_lsp::transport [ERROR] err <- "Trying to load configs for /home/stromae/Projects/webapp/evita/dashboard\n"
2022-08-01T18:28:26.133 helix_lsp::transport [ERROR] err <- "Loaded config at  /home/stromae/Projects/webapp/evita/dashboard/svelte.config.js\n"
2022-08-01T18:28:26.201 helix_lsp::transport [ERROR] err <- "SnapshotManager File Statistics:\n"
2022-08-01T18:28:26.201 helix_lsp::transport [ERROR] err <- "Project files: 105\n"
2022-08-01T18:28:26.201 helix_lsp::transport [ERROR] err <- "Svelte files: 61\n"
2022-08-01T18:28:26.201 helix_lsp::transport [ERROR] err <- "From node_modules: 0\n"
2022-08-01T18:28:26.201 helix_lsp::transport [ERROR] err <- "Total: 105\n"
2022-08-01T18:28:35.779 helix_term::application [WARN] failed to load theme `monokai_pro_maschine` - No such file or directory (os error 2)

Platform

Linux

Terminal Emulator

alacritty 0.11.0-dev (1df32309)

Helix Version

helix 22.05 (07019c3)

@myisaak myisaak added the C-bug Category: This is a bug label Aug 1, 2022
@the-mikedavis
Copy link
Member

Can you post a minimal example file that produces this behavior? I suspect it has something to do with that "☝️" glyph in the comment

@myisaak
Copy link
Author

myisaak commented Aug 1, 2022

Yes you're right, just removed the emoji and it no longer crashes.

@myisaak
Copy link
Author

myisaak commented Aug 1, 2022

I added a minimal example. Seems to only affect then using typescript with svelte:

<script lang="ts">
    // try to delete anything here (before the emoticon)
    // 👆 false parameter is required for svelte https://github.com/saadeghi/theme-change
</script>⏎ 

@the-mikedavis
Copy link
Member

It looks like we hit a panic when evaluating this stanza:

(
(script_element
(start_tag
(attribute
(quoted_attribute_value (attribute_value) @_lang)))
(raw_text) @injection.content)
(#match? @_lang "(ts|typescript)")
(#set! injection.language "typescript")
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tree-sitter Area: Tree-sitter C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants