chomosuke / typst-preview.nvim

Low latency typst preview for Neovim
GNU General Public License v3.0
218 stars 14 forks source link

Error when jumping from preview to code with line ending #35

Closed Jacobgarm closed 1 week ago

Jacobgarm commented 1 month ago

Steps to reproduce:

  1. Open typst file with contents
    
    2+2

d d

2. Use :TypstPreview
3. Press line with d's in preview

Neovim gives an error, and does not move the cursor. See below for error.

My linux distribution is Arch Linux
Neovim v0.10.0
Package is installed using Lazy.nvim
Preview runs in Firefox

Config (debug=true does not change behaviour):

return { 'chomosuke/typst-preview.nvim', lazy = false, -- or ft = 'typst' version = '0.3.*', config = function() require('typst-preview').setup { debug = true } end, build = function() require('typst-preview').update() end, }


Full output of :mes

:mes
[2024-05-20T20:36:28Z INFO typst_preview] Arguments: CliArguments {
preview: PreviewArgs {
data_plane_host: "127.0.0.1:0",
control_plane_host: "127.0.0.1:0",
enable_partial_rendering: true,
invert_colors: "never",
},
preview_mode: Document,
[2024-05-20T20:36:28Z INFO typst_ts_compiler::service::diag::console] /typing.typ: Compilation succeeded in 3.52758ms

Setting link
[2024-05-20T20:36:28Z INFO typst_preview] Static file server listening on: 127.0.0.1:38629
Opening preview with command: xdg-open http://127.0.0.1:38629
[2024-05-20T20:36:28Z DEBUG typst_ts_compiler::service::compile] CompileActor: fs event incoming Some(Update(FileChangeSet { removes: [], in g.typ", FileSnapshot { mtime: SystemTime { tv_sec: 1716237063, tv_nsec: 642787329 }, content: FileContent { len: 9 } })] }))
[2024-05-20T20:36:28Z INFO typst_ts_compiler::service::diag::console] /typing.typ: compiling ...

[2024-05-20T20:36:28Z INFO typst_ts_compiler::service::diag::console] /typing.typ: Compilation succeeded in 60.309µs

[2024-05-20T20:36:28Z INFO typst_preview] Peer address: 127.0.0.1:46536
[2024-05-20T20:36:28Z INFO typst_preview] New WebSocket connection: 127.0.0.1:46536
websocat said: {"event":"syncEditorChanges"}
{"event":"compileStatus","kind":"Compiling"}
{"event":"compileStatus","kind":"CompileSuccess"}
{"event":"compileStatus","kind":"Compiling"}
{"event":"compileStatus","kind":"CompileSuccess"}
[2024-05-20T20:36:28Z INFO typst_preview] Serve frontend: Document
[2024-05-20T20:36:29Z INFO typst_preview] Peer address: 127.0.0.1:54812
[2024-05-20T20:36:29Z INFO typst_preview] New WebSocket connection: 127.0.0.1:54812
[2024-05-20T20:36:29Z DEBUG typst_preview::actor::render] OutlineRenderActor: waiting for message
[2024-05-20T20:36:29Z DEBUG typst_preview::actor::render] RenderActor: waiting for message
[2024-05-20T20:36:29Z DEBUG typst_preview::actor::render] RenderActor: has_full_render: true
[2024-05-20T20:36:29Z DEBUG typst_preview::actor::render] OutlineRenderActor: received message: RenderFullLatest
[2024-05-20T20:36:29Z DEBUG typst_preview::actor::render] OutlineRenderActor: sending outline
[2024-05-20T20:36:29Z DEBUG typst_preview::actor::render] OutlineRenderActor: waiting for message
websocat said: {"event":"outline","items":[]}
[2024-05-20T20:36:29Z DEBUG typst_preview::actor::render] RenderActor: waiting for message
[2024-05-20T20:36:31Z INFO typst_preview::actor::render] RenderActor: resolving span: [ElementPoint { kind: 4, index: 0, fingerprint: "" }, ngerprint: "" }, ElementPoint { kind: 0, index: 1, fingerprint: "" }, ElementPoint { kind: 5, index: 3, fingerprint: "" }]
[2024-05-20T20:36:31Z INFO typst_ts_core::vector::pass::span2vec] lazy spans are initializing
[2024-05-20T20:36:31Z DEBUG typst_preview::actor::render] OutlineRenderActor: received message: ResolveSpan(ResolveSpanRequest([ElementPoint }, ElementPoint { kind: 1, index: 0, fingerprint: "" }, ElementPoint { kind: 0, index: 1, fingerprint: "" }, ElementPoint { kind: 5, index: [2024-05-20T20:36:31Z DEBUG typst_preview::actor::render] OutlineRenderActor: sending outline
[2024-05-20T20:36:31Z DEBUG typst_preview::actor::render] OutlineRenderActor: waiting for message
[2024-05-20T20:36:31Z INFO typst_ts_core::vector::pass::span2vec] pass check remote path([ElementPoint { kind: 4, index: 0, fingerprint: "" fingerprint: "" }, ElementPoint { kind: 0, index: 1, fingerprint: "" }, ElementPoint { kind: 5, index: 3, fingerprint: "" }])
[2024-05-20T20:36:31Z INFO typst_ts_core::vector::pass::span2vec] pass check remote(4, 0) => Page { region: 2 }
[2024-05-20T20:36:31Z INFO typst_ts_core::vector::pass::span2vec] pass check remote(1, 0) => Group { region: 3 }
[2024-05-20T20:36:31Z INFO typst_ts_core::vector::pass::span2vec] pass check remote(0, 1) => Text([(Span(351843720888320), 0), (Span(371949 ), 0)])52), 0), (Span(392054431846984
[2024-05-20T20:36:31Z INFO typst_ts_core::vector::pass::span2vec] pass check remote_char_index(5, 3) => Some([(Span(351843720888320), 0), ( [2024-05-20T20:36:29Z DEBUG typst_preview::actor::render] OutlineRenderActor: received message: RenderFullLatest
[2024-05-20T20:36:29Z DEBUG typst_preview::actor::render] OutlineRenderActor: sending outline
[2024-05-20T20:36:29Z DEBUG typst_preview::actor::render] OutlineRenderActor: waiting for message
websocat said: {"event":"outline","items":[]}
[2024-05-20T20:36:29Z DEBUG typst_preview::actor::render] RenderActor: waiting for message
[2024-05-20T20:36:31Z INFO typst_preview::actor::render] RenderActor: resolving span: [ElementPoint { kind: 4, index: 0, fingerprint: "" }, ngerprint: "" }, ElementPoint { kind: 0, index: 1, fingerprint: "" }, ElementPoint { kind: 5, index: 3, fingerprint: "" }]
[2024-05-20T20:36:31Z INFO typst_ts_core::vector::pass::span2vec] lazy spans are initializing
[2024-05-20T20:36:31Z DEBUG typst_preview::actor::render] OutlineRenderActor: received message: ResolveSpan(ResolveSpanRequest([ElementPoint }, ElementPoint { kind: 1, index: 0, fingerprint: "" }, ElementPoint { kind: 0, index: 1, fingerprint: "" }, ElementPoint { kind: 5, index: [2024-05-20T20:36:31Z DEBUG typst_preview::actor::render] OutlineRenderActor: sending outline
[2024-05-20T20:36:31Z DEBUG typst_preview::actor::render] OutlineRenderActor: waiting for message
[2024-05-20T20:36:31Z INFO typst_ts_core::vector::pass::span2vec] pass check remote path([ElementPoint { kind: 4, index: 0, fingerprint: "" fingerprint: "" }, ElementPoint { kind: 0, index: 1, fingerprint: "" }, ElementPoint { kind: 5, index: 3, fingerprint: "" }])
[2024-05-20T20:36:31Z INFO typst_ts_core::vector::pass::span2vec] pass check remote(4, 0) => Page { region: 2 }
[2024-05-20T20:36:31Z INFO typst_ts_core::vector::pass::span2vec] pass check remote(1, 0) => Group { region: 3 }
[2024-05-20T20:36:31Z INFO typst_ts_core::vector::pass::span2vec] pass check remote(0, 1) => Text([(Span(351843720888320), 0), (Span(371949 ), 0)]) [2024-05-20T20:36:31Z INFO typst_ts_core::vector::pass::span2vec] pass check remote_char_index(5, 3) => Some([(Span(351843720888320), 0), ( 54431846984), 0)])
[2024-05-20T20:36:31Z INFO typst_preview::actor::render] RenderActor: resolved span: Some((SourceSpanOffset { span: Span(351843720888320), Span(392054431846984), offset: 0 }))
[2024-05-20T20:36:31Z DEBUG typst_preview::actor::render] RenderActor: has_full_render: false
websocat said: {"event":"outline","items":[]}
[2024-05-20T20:36:31Z DEBUG typst_preview::actor::typst] TypstActor: processing doc2src: (SourceSpanOffset { span: Span(351843720888320), of pan(392054431846984), offset: 0 })
[2024-05-20T20:36:31Z DEBUG typst_ts_compiler::service::compile] CompileActor: execute task
[2024-05-20T20:36:31Z DEBUG typst_ts_compiler::service::compile] CompileActor: execute task
[2024-05-20T20:36:31Z DEBUG typst_preview::actor::render] RenderActor: waiting for message
[2024-05-20T20:36:31Z DEBUG typst_ts_compiler::service::compile] CompileActor: execute task
websocat said: {"event":"editorScrollTo","filepath":"/home/jacob/Documents/typing.typ","start":[3,0],"end":[3,0]}
Error executing vim.schedule lua callback: ...y/typst-preview.nvim/lua/typst-preview/events/server.lua:13: Column value outside range
stack traceback:
[C]: in function 'nvim_win_set_cursor'
...y/typst-preview.nvim/lua/typst-preview/events/server.lua:13: in function 'editorScrollTo'
...y/typst-preview.nvim/lua/typst-preview/events/server.lua:26: in function 'listener'
...azy/typst-preview.nvim/lua/typst-preview/server/init.lua:83: in function 'listener'
.../typst-preview.nvim/lua/typst-preview/server/factory.lua:166: in function ''
vim/_editor.lua: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>
3 0

chomosuke commented 1 week ago

Sorry for the late response, and thank you for pointing out this issue with me and giving me a minimum reproducible test. This will be addressed soon.