helix icon indicating copy to clipboard operation
helix copied to clipboard

Helix crashes with a `:reset-diff-change` and `goto_next_change` macro

Open benmuth opened this issue 1 year ago • 3 comments

Summary

I tried to reset some diff changes by recording a short macro: :reset-diff-change followed by goto_next_change. When trying to apply this macro to a few specific changes in quick succession, I caused a panic.

When trying to reproduce the crash, I noticed some other strange behavior with this macro, like "missing" the next change sometimes. I included that as well in a recording below. You can see the second diff block not being highlighted correctly.

Reproduction Steps

Here's the crash: asciicast

Here's some other strange behavior: asciicast

I tried this: Create a file with this text:

  const response = await fetch(
    "https://clipdrop-api.co/remove-background/v1",
    {
      method: "POST",
      body: formData,
      headers: {
        "x-api-key": process.env.CLIPDROP_API_KEY || "",
      },
    }
  );

  if (response.ok) {
    const arrayBuffer = await response.arrayBuffer();
    const contentType = response.headers.get("content-type") || "application/octet-stream";
    const blob = new Blob([arrayBuffer], { type: contentType });

    return new NextResponse(blob);
  } else {
    return NextResponse.json({ error: "Failed to remove image background, external API error" }, { status: 500 });
  }
}

Initialize a git repository, and commit this file. Then replace the contents of the file with this:

  // formData.append("image_file", image, "image.png");

  // const response = await fetch(
  //   "https://clipdrop-api.co/remove-background/v1",
  //   {
  //     method: "POST",
  //     body: formData,
  //     headers: {
  //       "x-api-key": process.env.CLIPDROP_API_KEY || "",
  //     },
  //   }
  // );

  return new NextResponse(no_bg_image)
  // if (response.ok) {
  //   const arrayBuffer = await response.arrayBuffer();
  //   const contentType = response.headers.get("content-type") || "application/octet-stream";
  //   const blob = new Blob([arrayBuffer], { type: contentType });

  //   return new NextResponse(blob);
  // } else {
  //   return NextResponse.json({ error: "Failed to remove image background, external API error" }, { status: 500 });
  // }
}

Then, place the cursor at the beginning of the file, and do the following key sequence: Q:reset-diff-change<enter>]gQq That is,

  1. start recording a macro
  2. reset the first diff change
  3. go to next diff change
  4. stop recording the macro
  5. perform the macro on the second diff block

Helix sometimes crashes on step 5, but it's pretty flaky. If it doesn't work, try rapidly executing the macro and pressing undo, repeatedly and randomly. I always see some buggy behavior with the second diff block at least, and sometimes it crashes.

Here's the stack trace I get:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Line index out of bounds: line index 32, Rope/RopeSlice line count 28', /Users/brew/Library/Caches/Homebrew/cargo_cache/registry/src/index.crates.io-6f17d22bba15001f/ropey-1.6.1/src/slice.rs:453:41
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: helix_core::selection::Selection::transform
   4: helix_term::commands::goto_next_change_impl::{{closure}}
   5: helix_view::editor::Editor::apply_motion
   6: helix_term::ui::editor::EditorView::handle_keymap_event::{{closure}}
   7: helix_term::ui::editor::EditorView::handle_keymap_event
   8: <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event
   9: helix_term::compositor::Compositor::handle_event
  10: core::ops::function::FnOnce::call_once{{vtable.shim}}
  11: helix_term::compositor::Compositor::handle_event
  12: helix_term::application::Application::run::{{closure}}
  13: tokio::runtime::park::CachedParkThread::block_on
  14: tokio::runtime::runtime::Runtime::block_on
  15: hx::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I expected this to happen: No crash, and/or no buggy behavior.

Instead, this happened: The opposite :)

Helix log

This log is for the case where it crashes.

~/.cache/helix/helix.log

2024-02-17T22:02:42.591 helix_view::theme [WARN] Theme: invalid modifier: ""
2024-02-17T22:02:42.591 helix_view::theme [WARN] Theme: invalid modifier: ""
2024-02-17T22:02:42.593 helix_view::clipboard [DEBUG] Using pbcopy+pbpaste to interact with the system clipboard
2024-02-17T22:02:42.597 helix_tui::backend::crossterm [DEBUG] The keyboard enhancement protocol is supported in this terminal (checked in 3.586708ms)
2024-02-17T22:02:42.597 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-02-17T22:02:42.695 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:43.088 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-02-17T22:02:43.189 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:43.239 globset [DEBUG] glob converted to regex: Glob { glob: "*.{zip,gz,bz2,zst,lzo,sz,tgz,tbz2,lz,lz4,lzma,lzo,z,Z,xz,7z,rar,cab}", re: "(?-u)^[^/]*\\.(?:cab|rar|7z|xz|Z|z|lzo|lzma|lz4|lz|tbz2|tgz|sz|lzo|zst|bz2|gz|zip)$", opts: GlobOptions { case_insensitive: false, literal_separator: true, backslash_escape: true, empty_alternates: false }, tokens: Tokens([ZeroOrMore, Literal('.'), Alternates([Tokens([Literal('c'), Literal('a'), Literal('b')]), Tokens([Literal('r'), Literal('a'), Literal('r')]), Tokens([Literal('7'), Literal('z')]), Tokens([Literal('x'), Literal('z')]), Tokens([Literal('Z')]), Tokens([Literal('z')]), Tokens([Literal('l'), Literal('z'), Literal('o')]), Tokens([Literal('l'), Literal('z'), Literal('m'), Literal('a')]), Tokens([Literal('l'), Literal('z'), Literal('4')]), Tokens([Literal('l'), Literal('z')]), Tokens([Literal('t'), Literal('b'), Literal('z'), Literal('2')]), Tokens([Literal('t'), Literal('g'), Literal('z')]), Tokens([Literal('s'), Literal('z')]), Tokens([Literal('l'), Literal('z'), Literal('o')]), Tokens([Literal('z'), Literal('s'), Literal('t')]), Tokens([Literal('b'), Literal('z'), Literal('2')]), Tokens([Literal('g'), Literal('z')]), Tokens([Literal('z'), Literal('i'), Literal('p')])])]) }
2024-02-17T22:02:43.239 globset [DEBUG] built glob set; 0 literals, 0 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 1 regexes
2024-02-17T22:02:43.241 helix_term::ui [DEBUG] file_picker init 4.57ms
2024-02-17T22:02:43.242 ignore::walk [DEBUG] ignoring /Users/ben/code/playground/web/hx-crash/.git: Ignore(IgnoreMatch(Hidden))
2024-02-17T22:02:43.243 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-02-17T22:02:43.338 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:43.340 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-02-17T22:02:44.063 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-02-17T22:02:44.165 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:44.165 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-02-17T22:02:44.223 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-02-17T22:02:44.300 helix_view::document [DEBUG] id 1 modified - last saved: 0, current: 0
2024-02-17T22:02:44.300 helix_lsp::client [INFO] Using custom LSP config: {"hostInfo":"helix","javascript":{"inlayHints":{"includeInlayEnumMemberValueHints":true,"includeInlayFunctionLikeReturnTypeHints":true,"includeInlayFunctionParameterTypeHints":true,"includeInlayParameterNameHints":"all","includeInlayParameterNameHintsWhenArgumentMatchesName":true,"includeInlayPropertyDeclarationTypeHints":true,"includeInlayVariableTypeHints":true}},"typescript":{"inlayHints":{"includeInlayEnumMemberValueHints":true,"includeInlayFunctionLikeReturnTypeHints":true,"includeInlayFunctionParameterTypeHints":true,"includeInlayParameterNameHints":"all","includeInlayParameterNameHintsWhenArgumentMatchesName":true,"includeInlayPropertyDeclarationTypeHints":true,"includeInlayVariableTypeHints":true}}}
2024-02-17T22:02:44.300 helix_lsp::transport [INFO] typescript-language-server -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dataSupport":true,"disabledSupport":true,"isPreferredSupport":true,"resolveSupport":{"properties":["edit","command"]}},"completion":{"completionItem":{"deprecatedSupport":true,"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"inlayHint":{"dynamicRegistration":false},"publishDiagnostics":{"versionSupport":true},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":true},"signatureHelp":{"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown"],"parameterInformation":{"labelOffsetSupport":true}}}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":false},"executeCommand":{"dynamicRegistration":false},"inlayHint":{"refreshSupport":false},"symbol":{"dynamicRegistration":false},"workspaceEdit":{"documentChanges":true,"failureHandling":"abort","normalizesLineEndings":false,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"helix","version":"23.10 (f6021dd0)"},"initializationOptions":{"hostInfo":"helix","javascript":{"inlayHints":{"includeInlayEnumMemberValueHints":true,"includeInlayFunctionLikeReturnTypeHints":true,"includeInlayFunctionParameterTypeHints":true,"includeInlayParameterNameHints":"all","includeInlayParameterNameHintsWhenArgumentMatchesName":true,"includeInlayPropertyDeclarationTypeHints":true,"includeInlayVariableTypeHints":true}},"typescript":{"inlayHints":{"includeInlayEnumMemberValueHints":true,"includeInlayFunctionLikeReturnTypeHints":true,"includeInlayFunctionParameterTypeHints":true,"includeInlayParameterNameHints":"all","includeInlayParameterNameHintsWhenArgumentMatchesName":true,"includeInlayPropertyDeclarationTypeHints":true,"includeInlayVariableTypeHints":true}}},"processId":43991,"rootPath":"/Users/ben/code/playground/web/hx-crash","rootUri":"file:///Users/ben/code/playground/web/hx-crash","workspaceFolders":[{"name":"hx-crash","uri":"file:///Users/ben/code/playground/web/hx-crash"}]},"id":0}
2024-02-17T22:02:44.300 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0
2024-02-17T22:02:44.396 helix_lsp::transport [INFO] typescript-language-server <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":2,"message":"Using Typescript version (bundled) 5.1.3 from path \"/Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/tsserver.js\""}}
2024-02-17T22:02:44.396 helix_lsp::transport [INFO] typescript-language-server <- {"jsonrpc":"2.0","id":0,"method":"window/workDoneProgress/create","params":{"token":"12364fbc-e17a-4146-8d69-bac650c6936a"}}
2024-02-17T22:02:44.396 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "window/logMessage", params: Map({"message": String("Using Typescript version (bundled) 5.1.3 from path \"/Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/tsserver.js\""), "type": Number(2)}) })))
2024-02-17T22:02:44.396 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Warning, message: "Using Typescript version (bundled) 5.1.3 from path \"/Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/tsserver.js\"" }
2024-02-17T22:02:44.396 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, MethodCall(MethodCall { jsonrpc: Some(V2), method: "window/workDoneProgress/create", params: Map({"token": String("12364fbc-e17a-4146-8d69-bac650c6936a")}), id: Num(0) })))
2024-02-17T22:02:44.396 helix_lsp::transport [INFO] typescript-language-server <- {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":2,"completionProvider":{"triggerCharacters":[".","\"","'","/","@","<"],"resolveProvider":true},"codeActionProvider":{"codeActionKinds":["source.fixAll.ts","source.removeUnused.ts","source.addMissingImports.ts","source.organizeImports.ts","source.removeUnusedImports.ts","source.sortImports.ts","quickfix","refactor"]},"definitionProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["_typescript.applyWorkspaceEdit","_typescript.applyCodeAction","_typescript.applyRefactoring","_typescript.configurePlugin","_typescript.organizeImports","_typescript.applyRenameFile","_typescript.goToSourceDefinition"]},"hoverProvider":true,"inlayHintProvider":true,"renameProvider":{"prepareProvider":true},"referencesProvider":true,"selectionRangeProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",",","<"],"retriggerCharacters":[")"]},"workspaceSymbolProvider":true,"implementationProvider":true,"typeDefinitionProvider":true,"foldingRangeProvider":true,"semanticTokensProvider":{"documentSelector":null,"legend":{"tokenTypes":["class","enum","interface","namespace","typeParameter","type","parameter","variable","enumMember","property","function","member"],"tokenModifiers":["declaration","static","async","readonly","defaultLibrary","local"]},"full":true,"range":true},"workspace":{"fileOperations":{"willRename":{"filters":[{"scheme":"file","pattern":{"glob":"**/*.{ts,js,jsx,tsx,mjs,mts,cjs,cts}","matches":"file"}}]}}}}}}
2024-02-17T22:02:44.396 helix_lsp::transport [INFO] Language server not initialized, delaying request
2024-02-17T22:02:44.396 helix_lsp::transport [INFO] typescript-language-server <- {"capabilities":{"codeActionProvider":{"codeActionKinds":["source.fixAll.ts","source.removeUnused.ts","source.addMissingImports.ts","source.organizeImports.ts","source.removeUnusedImports.ts","source.sortImports.ts","quickfix","refactor"]},"completionProvider":{"resolveProvider":true,"triggerCharacters":[".","\"","'","/","@","<"]},"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["_typescript.applyWorkspaceEdit","_typescript.applyCodeAction","_typescript.applyRefactoring","_typescript.configurePlugin","_typescript.organizeImports","_typescript.applyRenameFile","_typescript.goToSourceDefinition"]},"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"inlayHintProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"documentSelector":null,"full":true,"legend":{"tokenModifiers":["declaration","static","async","readonly","defaultLibrary","local"],"tokenTypes":["class","enum","interface","namespace","typeParameter","type","parameter","variable","enumMember","property","function","member"]},"range":true},"signatureHelpProvider":{"retriggerCharacters":[")"],"triggerCharacters":["(",",","<"]},"textDocumentSync":2,"typeDefinitionProvider":true,"workspace":{"fileOperations":{"willRename":{"filters":[{"pattern":{"glob":"**/*.{ts,js,jsx,tsx,mjs,mts,cjs,cts}","matches":"file"},"scheme":"file"}]}}},"workspaceSymbolProvider":true}}
2024-02-17T22:02:44.396 helix_lsp::transport [INFO] Draining pending message Response(Success(Success { jsonrpc: Some(V2), result: Null, id: Num(0) }))
2024-02-17T22:02:44.396 helix_lsp::transport [INFO] typescript-language-server -> {"jsonrpc":"2.0","result":null,"id":0}
2024-02-17T22:02:44.396 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: None, method: "initialized", params: None })))
2024-02-17T22:02:44.396 helix_lsp::transport [INFO] typescript-language-server -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2024-02-17T22:02:44.396 helix_lsp::transport [INFO] typescript-language-server -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"typescript","text":"  const response = await fetch(\n    \"https://clipdrop-api.co/remove-background/v1\",\n    {\n      method: \"POST\",\n      body: formData,\n      headers: {\n        \"x-api-key\": process.env.CLIPDROP_API_KEY || \"\",\n      },\n    }\n  );\n\n  if (response.ok) {\n    const arrayBuffer = await response.arrayBuffer();\n    const contentType = response.headers.get(\"content-type\") || \"application/octet-stream\";\n    const blob = new Blob([arrayBuffer], { type: contentType });\n\n    return new NextResponse(blob);\n  } else {\n    return NextResponse.json({ error: \"Failed to remove image background, external API error\" }, { status: 500 });\n  }\n}\n","uri":"file:///Users/ben/code/playground/web/hx-crash/ex.ts","version":0}}}
2024-02-17T22:02:44.396 helix_lsp::transport [INFO] typescript-language-server -> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"hostInfo":"helix","javascript":{"inlayHints":{"includeInlayEnumMemberValueHints":true,"includeInlayFunctionLikeReturnTypeHints":true,"includeInlayFunctionParameterTypeHints":true,"includeInlayParameterNameHints":"all","includeInlayParameterNameHintsWhenArgumentMatchesName":true,"includeInlayPropertyDeclarationTypeHints":true,"includeInlayVariableTypeHints":true}},"typescript":{"inlayHints":{"includeInlayEnumMemberValueHints":true,"includeInlayFunctionLikeReturnTypeHints":true,"includeInlayFunctionParameterTypeHints":true,"includeInlayParameterNameHints":"all","includeInlayParameterNameHintsWhenArgumentMatchesName":true,"includeInlayPropertyDeclarationTypeHints":true,"includeInlayVariableTypeHints":true}}}}}
2024-02-17T22:02:44.397 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:44.397 helix_lsp::transport [INFO] typescript-language-server <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"12364fbc-e17a-4146-8d69-bac650c6936a","value":{"kind":"begin","title":"Initializing JS/TS language features…"}}}
2024-02-17T22:02:44.397 helix_lsp::transport [INFO] typescript-language-server <- {"jsonrpc":"2.0","method":"$/typescriptVersion","params":{"version":"5.1.3","source":"bundled"}}
2024-02-17T22:02:44.397 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0
2024-02-17T22:02:44.397 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "$/progress", params: Map({"token": String("12364fbc-e17a-4146-8d69-bac650c6936a"), "value": Object {"kind": String("begin"), "title": String("Initializing JS/TS language features…")}}) })))
2024-02-17T22:02:44.398 helix_lsp::transport [INFO] typescript-language-server -> {"jsonrpc":"2.0","method":"textDocument/inlayHint","params":{"range":{"end":{"character":0,"line":21},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///Users/ben/code/playground/web/hx-crash/ex.ts"}},"id":1}
2024-02-17T22:02:44.398 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "$/typescriptVersion", params: Map({"source": String("bundled"), "version": String("5.1.3")}) })))
2024-02-17T22:02:44.398 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2024-02-17T22:02:44.433 helix_term::application [DEBUG] received editor event: Redraw
2024-02-17T22:02:44.433 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0
2024-02-17T22:02:45.163 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0
2024-02-17T22:02:45.192 helix_lsp::transport [INFO] typescript-language-server <- {"jsonrpc":"2.0","id":1,"result":[{"position":{"line":1,"character":4},"label":"input:","kind":2,"paddingRight":true},{"position":{"line":2,"character":4},"label":"init:","kind":2,"paddingRight":true},{"position":{"line":13,"character":21},"label":": string","kind":1,"paddingLeft":true},{"position":{"line":13,"character":45},"label":"name:","kind":2,"paddingRight":true},{"position":{"line":14,"character":26},"label":"blobParts:","kind":2,"paddingRight":true},{"position":{"line":14,"character":41},"label":"options:","kind":2,"paddingRight":true}]}
2024-02-17T22:02:45.192 helix_lsp::transport [INFO] typescript-language-server <- [{"kind":2,"label":"input:","paddingRight":true,"position":{"character":4,"line":1}},{"kind":2,"label":"init:","paddingRight":true,"position":{"character":4,"line":2}},{"kind":1,"label":": string","paddingLeft":true,"position":{"character":21,"line":13}},{"kind":2,"label":"name:","paddingRight":true,"position":{"character":45,"line":13}},{"kind":2,"label":"blobParts:","paddingRight":true,"position":{"character":26,"line":14}},{"kind":2,"label":"options:","paddingRight":true,"position":{"character":41,"line":14}}]
2024-02-17T22:02:45.192 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0
2024-02-17T22:02:45.193 helix_lsp::transport [INFO] typescript-language-server <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"12364fbc-e17a-4146-8d69-bac650c6936a","value":{"kind":"end"}}}
2024-02-17T22:02:45.193 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "$/progress", params: Map({"token": String("12364fbc-e17a-4146-8d69-bac650c6936a"), "value": Object {"kind": String("end")}}) })))
2024-02-17T22:02:45.228 helix_term::application [DEBUG] received editor event: Redraw
2024-02-17T22:02:45.228 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0
2024-02-17T22:02:45.265 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:45.273 helix_lsp::transport [INFO] typescript-language-server <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/ben/code/playground/web/hx-crash/ex.ts","diagnostics":[{"range":{"start":{"line":20,"character":0},"end":{"line":20,"character":1}},"message":"Declaration or statement expected.","severity":1,"code":1128,"source":"typescript"},{"range":{"start":{"line":4,"character":12},"end":{"line":4,"character":20}},"message":"Cannot find name 'formData'. Did you mean 'FormData'?","severity":1,"code":2552,"source":"typescript","relatedInformation":[{"location":{"uri":"file:///Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/lib.dom.d.ts","range":{"start":{"line":8586,"character":12},"end":{"line":8586,"character":20}}},"message":"'FormData' is declared here."}]},{"range":{"start":{"line":6,"character":21},"end":{"line":6,"character":28}},"message":"Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.","severity":1,"code":2580,"source":"typescript"},{"range":{"start":{"line":16,"character":15},"end":{"line":16,"character":27}},"message":"Cannot find name 'NextResponse'. Did you mean 'Response'?","severity":1,"code":2552,"source":"typescript","relatedInformation":[{"location":{"uri":"file:///Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/lib.dom.d.ts","range":{"start":{"line":18747,"character":12},"end":{"line":18747,"character":20}}},"message":"'Response' is declared here."}]},{"range":{"start":{"line":18,"character":11},"end":{"line":18,"character":23}},"message":"Cannot find name 'NextResponse'. Did you mean 'Response'?","severity":1,"code":2552,"source":"typescript","relatedInformation":[{"location":{"uri":"file:///Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/lib.dom.d.ts","range":{"start":{"line":18747,"character":12},"end":{"line":18747,"character":20}}},"message":"'Response' is declared here."}]}]}}
2024-02-17T22:02:45.273 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "textDocument/publishDiagnostics", params: Map({"diagnostics": Array [Object {"code": Number(1128), "message": String("Declaration or statement expected."), "range": Object {"end": Object {"character": Number(1), "line": Number(20)}, "start": Object {"character": Number(0), "line": Number(20)}}, "severity": Number(1), "source": String("typescript")}, Object {"code": Number(2552), "message": String("Cannot find name 'formData'. Did you mean 'FormData'?"), "range": Object {"end": Object {"character": Number(20), "line": Number(4)}, "start": Object {"character": Number(12), "line": Number(4)}}, "relatedInformation": Array [Object {"location": Object {"range": Object {"end": Object {"character": Number(20), "line": Number(8586)}, "start": Object {"character": Number(12), "line": Number(8586)}}, "uri": String("file:///Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/lib.dom.d.ts")}, "message": String("'FormData' is declared here.")}], "severity": Number(1), "source": String("typescript")}, Object {"code": Number(2580), "message": String("Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`."), "range": Object {"end": Object {"character": Number(28), "line": Number(6)}, "start": Object {"character": Number(21), "line": Number(6)}}, "severity": Number(1), "source": String("typescript")}, Object {"code": Number(2552), "message": String("Cannot find name 'NextResponse'. Did you mean 'Response'?"), "range": Object {"end": Object {"character": Number(27), "line": Number(16)}, "start": Object {"character": Number(15), "line": Number(16)}}, "relatedInformation": Array [Object {"location": Object {"range": Object {"end": Object {"character": Number(20), "line": Number(18747)}, "start": Object {"character": Number(12), "line": Number(18747)}}, "uri": String("file:///Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/lib.dom.d.ts")}, "message": String("'Response' is declared here.")}], "severity": Number(1), "source": String("typescript")}, Object {"code": Number(2552), "message": String("Cannot find name 'NextResponse'. Did you mean 'Response'?"), "range": Object {"end": Object {"character": Number(23), "line": Number(18)}, "start": Object {"character": Number(11), "line": Number(18)}}, "relatedInformation": Array [Object {"location": Object {"range": Object {"end": Object {"character": Number(20), "line": Number(18747)}, "start": Object {"character": Number(12), "line": Number(18747)}}, "uri": String("file:///Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/lib.dom.d.ts")}, "message": String("'Response' is declared here.")}], "severity": Number(1), "source": String("typescript")}], "uri": String("file:///Users/ben/code/playground/web/hx-crash/ex.ts")}) })))
2024-02-17T22:02:45.308 helix_term::application [DEBUG] received editor event: Redraw
2024-02-17T22:02:45.308 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0
2024-02-17T22:02:45.803 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 0
2024-02-17T22:02:45.903 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:46.058 helix_lsp::transport [INFO] typescript-language-server -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":0,"line":21},"start":{"character":0,"line":0}},"text":"  // formData.append(\"image_file\", image, \"image.png\");\n\n  // const response = await fetch(\n  //   \"https://clipdrop-api.co/remove-background/v1\",\n  //   {\n  //     method: \"POST\",\n  //     body: formData,\n  //     headers: {\n  //       \"x-api-key\": process.env.CLIPDROP_API_KEY || \"\",\n  //     },\n  //   }\n  // );\n\n  return new NextResponse(no_bg_image)\n  // if (response.ok) {\n  //   const arrayBuffer = await response.arrayBuffer();\n  //   const contentType = response.headers.get(\"content-type\") || \"application/octet-stream\";\n  //   const blob = new Blob([arrayBuffer], { type: contentType });\n\n  //   return new NextResponse(blob);\n  // } else {\n  //   return NextResponse.json({ error: \"Failed to remove image background, external API error\" }, { status: 500 });\n  // }\n}\n"}],"textDocument":{"uri":"file:///Users/ben/code/playground/web/hx-crash/ex.ts","version":1}}}
2024-02-17T22:02:46.059 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:46.127 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:46.127 helix_lsp::transport [INFO] typescript-language-server -> {"jsonrpc":"2.0","method":"textDocument/inlayHint","params":{"range":{"end":{"character":0,"line":24},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///Users/ben/code/playground/web/hx-crash/ex.ts"}},"id":2}
2024-02-17T22:02:46.138 helix_lsp::transport [INFO] typescript-language-server <- {"jsonrpc":"2.0","id":2,"result":[]}
2024-02-17T22:02:46.139 helix_lsp::transport [INFO] typescript-language-server <- []
2024-02-17T22:02:46.140 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:46.328 helix_lsp::transport [INFO] typescript-language-server <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/ben/code/playground/web/hx-crash/ex.ts","diagnostics":[{"range":{"start":{"line":23,"character":0},"end":{"line":23,"character":1}},"message":"Declaration or statement expected.","severity":1,"code":1128,"source":"typescript"},{"range":{"start":{"line":13,"character":13},"end":{"line":13,"character":25}},"message":"Cannot find name 'NextResponse'. Did you mean 'Response'?","severity":1,"code":2552,"source":"typescript","relatedInformation":[{"location":{"uri":"file:///Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/lib.dom.d.ts","range":{"start":{"line":18747,"character":12},"end":{"line":18747,"character":20}}},"message":"'Response' is declared here."}]},{"range":{"start":{"line":13,"character":26},"end":{"line":13,"character":37}},"message":"Cannot find name 'no_bg_image'.","severity":1,"code":2304,"source":"typescript"}]}}
2024-02-17T22:02:46.328 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "textDocument/publishDiagnostics", params: Map({"diagnostics": Array [Object {"code": Number(1128), "message": String("Declaration or statement expected."), "range": Object {"end": Object {"character": Number(1), "line": Number(23)}, "start": Object {"character": Number(0), "line": Number(23)}}, "severity": Number(1), "source": String("typescript")}, Object {"code": Number(2552), "message": String("Cannot find name 'NextResponse'. Did you mean 'Response'?"), "range": Object {"end": Object {"character": Number(25), "line": Number(13)}, "start": Object {"character": Number(13), "line": Number(13)}}, "relatedInformation": Array [Object {"location": Object {"range": Object {"end": Object {"character": Number(20), "line": Number(18747)}, "start": Object {"character": Number(12), "line": Number(18747)}}, "uri": String("file:///Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/lib.dom.d.ts")}, "message": String("'Response' is declared here.")}], "severity": Number(1), "source": String("typescript")}, Object {"code": Number(2304), "message": String("Cannot find name 'no_bg_image'."), "range": Object {"end": Object {"character": Number(37), "line": Number(13)}, "start": Object {"character": Number(26), "line": Number(13)}}, "severity": Number(1), "source": String("typescript")}], "uri": String("file:///Users/ben/code/playground/web/hx-crash/ex.ts")}) })))
2024-02-17T22:02:46.364 helix_term::application [DEBUG] received editor event: Redraw
2024-02-17T22:02:46.367 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:46.715 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:46.815 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:46.851 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:46.952 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:47.808 helix_lsp::transport [INFO] typescript-language-server <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/ben/code/playground/web/hx-crash/ex.ts","diagnostics":[{"range":{"start":{"line":23,"character":0},"end":{"line":23,"character":1}},"message":"Declaration or statement expected.","severity":1,"code":1128,"source":"typescript"},{"range":{"start":{"line":13,"character":13},"end":{"line":13,"character":25}},"message":"Cannot find name 'NextResponse'. Did you mean 'Response'?","severity":1,"code":2552,"source":"typescript","relatedInformation":[{"location":{"uri":"file:///Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/lib.dom.d.ts","range":{"start":{"line":18747,"character":12},"end":{"line":18747,"character":20}}},"message":"'Response' is declared here."}]},{"range":{"start":{"line":13,"character":26},"end":{"line":13,"character":37}},"message":"Cannot find name 'no_bg_image'.","severity":1,"code":2304,"source":"typescript"}]}}
2024-02-17T22:02:47.809 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "textDocument/publishDiagnostics", params: Map({"diagnostics": Array [Object {"code": Number(1128), "message": String("Declaration or statement expected."), "range": Object {"end": Object {"character": Number(1), "line": Number(23)}, "start": Object {"character": Number(0), "line": Number(23)}}, "severity": Number(1), "source": String("typescript")}, Object {"code": Number(2552), "message": String("Cannot find name 'NextResponse'. Did you mean 'Response'?"), "range": Object {"end": Object {"character": Number(25), "line": Number(13)}, "start": Object {"character": Number(13), "line": Number(13)}}, "relatedInformation": Array [Object {"location": Object {"range": Object {"end": Object {"character": Number(20), "line": Number(18747)}, "start": Object {"character": Number(12), "line": Number(18747)}}, "uri": String("file:///Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/lib.dom.d.ts")}, "message": String("'Response' is declared here.")}], "severity": Number(1), "source": String("typescript")}, Object {"code": Number(2304), "message": String("Cannot find name 'no_bg_image'."), "range": Object {"end": Object {"character": Number(37), "line": Number(13)}, "start": Object {"character": Number(26), "line": Number(13)}}, "severity": Number(1), "source": String("typescript")}], "uri": String("file:///Users/ben/code/playground/web/hx-crash/ex.ts")}) })))
2024-02-17T22:02:47.844 helix_term::application [DEBUG] received editor event: Redraw
2024-02-17T22:02:47.847 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:47.907 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:48.008 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:48.789 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:49.388 helix_view::editor [DEBUG] editor status: Recording to register [@]
2024-02-17T22:02:49.389 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:49.490 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:50.301 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:50.402 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:50.787 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:50.816 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:51.006 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:51.039 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:53.647 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 1
2024-02-17T22:02:55.948 helix_lsp::transport [INFO] typescript-language-server -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":0,"line":1},"start":{"character":0,"line":0}},"text":"  const response = await fetch(\n    \"https://clipdrop-api.co/remove-background/v1\",\n    {\n      method: \"POST\",\n      body: formData,\n      headers: {\n        \"x-api-key\": process.env.CLIPDROP_API_KEY || \"\",\n      },\n    }\n  );\n"}],"textDocument":{"uri":"file:///Users/ben/code/playground/web/hx-crash/ex.ts","version":2}}}
2024-02-17T22:02:55.951 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 2
2024-02-17T22:02:56.222 helix_lsp::transport [INFO] typescript-language-server <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/ben/code/playground/web/hx-crash/ex.ts","diagnostics":[{"range":{"start":{"line":32,"character":0},"end":{"line":32,"character":1}},"message":"Declaration or statement expected.","severity":1,"code":1128,"source":"typescript"},{"range":{"start":{"line":4,"character":12},"end":{"line":4,"character":20}},"message":"Cannot find name 'formData'. Did you mean 'FormData'?","severity":1,"code":2552,"source":"typescript","relatedInformation":[{"location":{"uri":"file:///Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/lib.dom.d.ts","range":{"start":{"line":8586,"character":12},"end":{"line":8586,"character":20}}},"message":"'FormData' is declared here."}]},{"range":{"start":{"line":6,"character":21},"end":{"line":6,"character":28}},"message":"Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.","severity":1,"code":2580,"source":"typescript"}]}}
2024-02-17T22:02:56.223 helix_term::application [DEBUG] received editor event: LanguageServerMessage((0, Notification(Notification { jsonrpc: Some(V2), method: "textDocument/publishDiagnostics", params: Map({"diagnostics": Array [Object {"code": Number(1128), "message": String("Declaration or statement expected."), "range": Object {"end": Object {"character": Number(1), "line": Number(32)}, "start": Object {"character": Number(0), "line": Number(32)}}, "severity": Number(1), "source": String("typescript")}, Object {"code": Number(2552), "message": String("Cannot find name 'formData'. Did you mean 'FormData'?"), "range": Object {"end": Object {"character": Number(20), "line": Number(4)}, "start": Object {"character": Number(12), "line": Number(4)}}, "relatedInformation": Array [Object {"location": Object {"range": Object {"end": Object {"character": Number(20), "line": Number(8586)}, "start": Object {"character": Number(12), "line": Number(8586)}}, "uri": String("file:///Users/ben/.nvm/versions/node/v18.15.0/lib/node_modules/typescript/lib/lib.dom.d.ts")}, "message": String("'FormData' is declared here.")}], "severity": Number(1), "source": String("typescript")}, Object {"code": Number(2580), "message": String("Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`."), "range": Object {"end": Object {"character": Number(28), "line": Number(6)}, "start": Object {"character": Number(21), "line": Number(6)}}, "severity": Number(1), "source": String("typescript")}], "uri": String("file:///Users/ben/code/playground/web/hx-crash/ex.ts")}) })))
2024-02-17T22:02:56.258 helix_term::application [DEBUG] received editor event: Redraw
2024-02-17T22:02:56.261 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 2
2024-02-17T22:02:56.578 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 2
2024-02-17T22:02:56.678 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:56.678 helix_lsp::transport [INFO] typescript-language-server -> {"jsonrpc":"2.0","method":"textDocument/inlayHint","params":{"range":{"end":{"character":0,"line":33},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///Users/ben/code/playground/web/hx-crash/ex.ts"}},"id":3}
2024-02-17T22:02:56.685 helix_lsp::transport [INFO] typescript-language-server <- {"jsonrpc":"2.0","id":3,"result":[{"position":{"line":1,"character":4},"label":"input:","kind":2,"paddingRight":true},{"position":{"line":2,"character":4},"label":"init:","kind":2,"paddingRight":true}]}
2024-02-17T22:02:56.685 helix_lsp::transport [INFO] typescript-language-server <- [{"kind":2,"label":"input:","paddingRight":true,"position":{"character":4,"line":1}},{"kind":2,"label":"init:","paddingRight":true,"position":{"character":4,"line":2}}]
2024-02-17T22:02:56.686 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 2
2024-02-17T22:02:56.693 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 2
2024-02-17T22:02:56.794 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:58.619 helix_view::editor [DEBUG] editor status: Recorded to register [@]
2024-02-17T22:02:58.621 helix_view::document [DEBUG] id 2 modified - last saved: 0, current: 2
2024-02-17T22:02:58.721 helix_term::application [DEBUG] received editor event: IdleTimer
2024-02-17T22:02:59.194 helix_lsp::transport [INFO] typescript-language-server -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":0,"line":21},"start":{"character":0,"line":11}},"text":"  if (response.ok) {\n    const arrayBuffer = await response.arrayBuffer();\n    const contentType = response.headers.get(\"content-type\") || \"application/octet-stream\";\n    const blob = new Blob([arrayBuffer], { type: contentType });\n"}],"textDocument":{"uri":"file:///Users/ben/code/playground/web/hx-crash/ex.ts","version":3}}}
2024-02-17T22:02:59.228 helix_vcs::diff::worker [INFO] Diff computation timed out, update of diffs might appear delayed

Platform

macOS

Terminal Emulator

kitty 0.32.1

Installation Method

brew

Helix Version

helix 23.10 (f6021dd0)

benmuth avatar Feb 18 '24 04:02 benmuth

I had also some macro weirdness, Never a crash, only text corrupting behavior. Perhaps it's the same bug. I never managed to reproduce it. In about 200 days of using I had text corrupting only three times.

The last time, yesterday, I recorded a simple macro (P A-; j), executed it a few times, then recorded another macro and during that suddenly Helix hung for a few seconds and the affected buffers had about 100 to 300 more history entries. I have the suspicion that macros mess up the history. It looks like some history parts get accidentally duplicated and re-applied on more than one buffer. It also does not happen immediately.

Good luck in finding the bug! If I find out more, I will post here.

EDIT: Today (2024-02-21) I had another macro weirdness, but this time it was extremely catastrophic. My macro went havoc and even executed some :w commands from bogus buffer contents. I dismayedly watched trunk trying to rebuild about half a dozen times. Then Helix crashed after a minute. I had to restore from my last git commit because my source code got machine-gunned and could not be saved. Sorry, I don't have specifics because I panicked. I know, macros are an experimental feature, but today I learned, they are extremely dangerous. Sorry to spam this issue, but I feel it is not impossible that what @benmuth and I experienced, are related.

It's probably not undo history related because the undo history does not contain commands but only edits, right? It looks for me like the macro suddenly executed wrong data. Also, like the last time, more than one file was affected.

nalply avatar Feb 18 '24 06:02 nalply

Full backtrace...
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Line index out of bounds: line index 32, Rope/RopeSlice line count 28', /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ropey-1.6.1/src/slice.rs:453:41
stack backtrace:
   0:     0x55baefb4d85a - std::backtrace_rs::backtrace::libunwind::trace::h9a6b80bbf328ba5d
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55baefb4d85a - std::backtrace_rs::backtrace::trace_unsynchronized::hd162ec543a11886b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55baefb4d85a - std::sys_common::backtrace::_print_fmt::h78a5099be12f51a6
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x55baefb4d85a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha1c5390454d74f71
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x55baefb7be0f - core::fmt::write::h9ffde816c577717b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/fmt/mod.rs:1254:17
   5:     0x55baefb47a15 - std::io::Write::write_fmt::h88186074961638e4
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/io/mod.rs:1698:15
   6:     0x55baefb4d625 - std::sys_common::backtrace::_print::h184198273ed08d59
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x55baefb4d625 - std::sys_common::backtrace::print::h1b4d8e7add699453
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x55baefb4f35e - std::panicking::default_hook::{{closure}}::h393bcea75423915a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:269:22
   9:     0x55baefb4f105 - std::panicking::default_hook::h48c64f31d8b3fd03
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:288:9
  10:     0x55baedb11b03 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::ha2c6ae983bbccf57
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1987:9
  11:     0x55baedb71716 - helix_term::application::Application::run::{{closure}}::{{closure}}::hbeb3a2633d955213
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/application.rs:1198:13
  12:     0x55baefb4faa4 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hb9b860f5a1175bda
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1987:9
  13:     0x55baefb4faa4 - std::panicking::rust_panic_with_hook::hafdc493a79370062
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:695:13
  14:     0x55baefb4f819 - std::panicking::begin_panic_handler::{{closure}}::h0a64bc82e36bedc7
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:582:13
  15:     0x55baefb4dcc6 - std::sys_common::backtrace::__rust_end_short_backtrace::hc203444fb7416a16
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:150:18
  16:     0x55baefb4f572 - rust_begin_unwind
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
  17:     0x55baefb78fe3 - core::panicking::panic_fmt::h0f6ef0178afce4f2
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
  18:     0x55baefb79583 - core::result::unwrap_failed::h8090202169109f9c
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/result.rs:1687:5
  19:     0x55baef684f66 - core::result::Result<T,E>::unwrap::h24b64bd1018ee4df
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/result.rs:1089:23
  20:     0x55baee3b0dc0 - ropey::slice::RopeSlice::line_to_char::ha8ebfe6fa6ae1b1c
                               at /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ropey-1.6.1/src/slice.rs:453:9
  21:     0x55baedf4a55b - helix_term::commands::hunk_range::hf06073cfdf968b15
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/commands.rs:3482:9
  22:     0x55baedd6a978 - helix_term::commands::goto_next_change_impl::{{closure}}::{{closure}}::hf913e6b7f4e595cb
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/commands.rs:3455:29
  23:     0x55baeddb01c2 - helix_core::selection::Selection::transform::h60cac842260ae1a4
                               at /nix/persist/home/michael/src/helix/hx/helix-core/src/selection.rs:601:22
  24:     0x55baedd6a667 - helix_term::commands::goto_next_change_impl::{{closure}}::h257c2f94a0ab41f3
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/commands.rs:3439:25
  25:     0x55baee337f6b - helix_view::editor::Editor::apply_motion::h9e658e6261f3f06d
                               at /nix/persist/home/michael/src/helix/hx/helix-view/src/editor.rs:1097:9
  26:     0x55baedf4a4d4 - helix_term::commands::goto_next_change_impl::he1bb1e99b4ebded7
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/commands.rs:3471:5
  27:     0x55baedf4a42c - helix_term::commands::goto_next_change::hb7d7567c874f707e
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/commands.rs:3420:5
  28:     0x55baedf39e3d - helix_term::commands::MappableCommand::execute::h02cc3b8f9529fcb3
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/commands.rs:208:41
  29:     0x55baedca1525 - helix_term::ui::editor::EditorView::handle_keymap_event::{{closure}}::h0368e522012521cd
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/ui/editor.rs:837:13
  30:     0x55baedbe3dcc - helix_term::ui::editor::EditorView::handle_keymap_event::h59fbe89df5fb018c
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/ui/editor.rs:863:17
  31:     0x55baedbe46bd - helix_term::ui::editor::EditorView::command_mode::h4d3d9b90fcb0248e
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/ui/editor.rs:971:17
  32:     0x55baedbe7d82 - <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event::heb4e991bab095e3b
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/ui/editor.rs:1336:33
  33:     0x55baedf0200e - helix_term::compositor::Compositor::handle_event::h257087279ab3a488
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/compositor.rs:152:19
  34:     0x55baedd73973 - helix_term::commands::replay_macro::{{closure}}::hce93cd36a4d6120f
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/commands.rs:5592:17
  35:     0x55baedbfb5c0 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h6d4ac3f91f6a7566
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
  36:     0x55baedcdd742 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h11e7b8b4a4b1d9b8
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1973:9
  37:     0x55baedca1d48 - <helix_term::ui::editor::EditorView as helix_term::compositor::Component>::handle_event::{{closure}}::hff2bb5805659fb5b
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/ui/editor.rs:1371:29
  38:     0x55baedbfc040 - core::ops::function::FnOnce::call_once{{vtable.shim}}::ha1801f5d0d36e04c
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
  39:     0x55baedcdd742 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h11e7b8b4a4b1d9b8
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/alloc/src/boxed.rs:1973:9
  40:     0x55baedf02237 - helix_term::compositor::Compositor::handle_event::h257087279ab3a488
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/compositor.rs:170:13
  41:     0x55baedb68eb4 - helix_term::application::Application::handle_terminal_events::{{closure}}::h9bdf57c7bb89aba5
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/application.rs:647:22
  42:     0x55baedb67836 - helix_term::application::Application::event_loop_until_idle::{{closure}}::hcd778d3fb1fe4c95
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/application.rs:320:55
  43:     0x55baedb64b84 - helix_term::application::Application::event_loop::{{closure}}::hd941856a1f7a117e
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/application.rs:294:57
  44:     0x55baedb7121f - helix_term::application::Application::run::{{closure}}::hf613fe14410d630e
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/application.rs:1201:38
  45:     0x55baedb42a34 - hx::main_impl::{{closure}}::hca2984cb090292f2
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/main.rs:161:53
  46:     0x55baedb4c403 - tokio::runtime::park::CachedParkThread::block_on::{{closure}}::h53366992537597f7
                               at /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/park.rs:281:63
  47:     0x55baedb4bd22 - tokio::runtime::coop::with_budget::hc910db2096c7ca10
                               at /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/coop.rs:107:5
  48:     0x55baedb4bd22 - tokio::runtime::coop::budget::hd89ff344e60c7d83
                               at /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/coop.rs:73:5
  49:     0x55baedb4bd22 - tokio::runtime::park::CachedParkThread::block_on::h287099c02ac3d582
                               at /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/park.rs:281:31
  50:     0x55baedb4a902 - tokio::runtime::context::blocking::BlockingRegionGuard::block_on::h502ddec5e446827a
                               at /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context/blocking.rs:66:9
  51:     0x55baedb1b6af - tokio::runtime::scheduler::multi_thread::MultiThread::block_on::{{closure}}::h4faffc855b59c4e9
                               at /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/mod.rs:87:13
  52:     0x55baedb7bec8 - tokio::runtime::context::runtime::enter_runtime::h7172a3d4a2c36118
                               at /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/context/runtime.rs:65:16
  53:     0x55baedb1b660 - tokio::runtime::scheduler::multi_thread::MultiThread::block_on::hd422ed6ef6f59853
                               at /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/scheduler/multi_thread/mod.rs:86:9
  54:     0x55baedb9b367 - tokio::runtime::runtime::Runtime::block_on::hb49a67e40d20d988
                               at /home/michael/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.36.0/src/runtime/runtime.rs:350:45
  55:     0x55baedb4cb7b - hx::main_impl::h23c31a3d7fbd1e65
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/main.rs:163:5
  56:     0x55baedb4c9ee - hx::main::he2618bb6ede6a539
                               at /nix/persist/home/michael/src/helix/hx/helix-term/src/main.rs:37:21
  57:     0x55baedb89dcb - core::ops::function::FnOnce::call_once::hb3002fa390b19945
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:250:5
  58:     0x55baedb6399e - std::sys_common::backtrace::__rust_begin_short_backtrace::h9b4e10881a1a8e8f
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:134:18
  59:     0x55baedb26e31 - std::rt::lang_start::{{closure}}::h7ebd8689f51a6486
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:166:18
  60:     0x55baefb3f30e - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hb1327dc2ef3fecdf
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:287:13
  61:     0x55baefb3f30e - std::panicking::try::do_call::h4044173225fe83dd
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
  62:     0x55baefb3f30e - std::panicking::try::hd8a722c09d156a53
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
  63:     0x55baefb3f30e - std::panic::catch_unwind::hd2ca07971cf0119b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
  64:     0x55baefb3f30e - std::rt::lang_start_internal::{{closure}}::h26d89d595cf47b70
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:148:48
  65:     0x55baefb3f30e - std::panicking::try::do_call::hf47aa1aa005e5f1a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
  66:     0x55baefb3f30e - std::panicking::try::h73d246b2423eaf4e
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
  67:     0x55baefb3f30e - std::panic::catch_unwind::hbaaeae8f1b2f9915
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
  68:     0x55baefb3f30e - std::rt::lang_start_internal::h76f3e81e6b8f13f9
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:148:20
  69:     0x55baedb26e0a - std::rt::lang_start::hd2ba24453607509d
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:165:17
  70:     0x55baedb4cc2e - main
  71:     0x7ff904338fce - __libc_start_call_main
  72:     0x7ff904339089 - __libc_start_main_impl
  73:     0x55baedb006a5 - _start
  74:                0x0 - <unknown>

the-mikedavis avatar Feb 18 '24 13:02 the-mikedavis

yeah, this makes sense, diff combination runs in a background thread and is only synchronized once we render the next frame. We can't/don't check if the diff is up to date yet (and create an error if not) so if running any commands that access a diff as part of a macro or a keybinding that modifies the buffer before running reset-diff-change the diff can be out of date.

The way to fix this would be to detect if the diff is out of date and produce an error if it is. That won't fix this usecase but it would prevent a crash. In theory we could also try to acquire the render lock here to force the diff to be up to date but since the render lock may be used for other things aswell in the future that feels very hacky to me

pascalkuthe avatar Feb 18 '24 23:02 pascalkuthe