Closed Samasaur1 closed 1 month ago
I finally had a bit of time to look into this but I couldn't reproduce with the current main
branch. Could you send over a raw minimal ipynb
file that shows the problem and your config?
Okay, sorry, I had some trouble tracking down the specific file that was causing issues. Here's the error message I was getting:
Error detected while processing BufReadd Autocommands for "*. ipynb":
Error executing lua callback: ...NeovimPackages/start/jupytext-nvim/Lua/jupytext/init.Lua:97: 'replacement string' item contains newlines
stack traceback:
[C]: in function 'nvim buf set lines'
...NeovimPackages/start/jupytext-nvim/lua/jupytext/init.lua:97: in function 'read_from_ipynb'
...NeovimPackages/start/jupytext-nvim/lua/jupytext/init.lua:176: in function <...NeovimPackages/start/jupytext-nvim/lua/jupytext/init.lua:175>
The actual issue is not \n
in the source code, as I thought, but is actually null bytes. This does mean that this PR is wrong, because it shouldn't put newlines in the generated file, but I'm pushing a new commit that correctly substitutes.
An example file (zipped) is attached: example.ipynb.zip
Hi @Samasaur1 I have finally decided against merging this PR. I think that having null bytes within "normal" code is an uncommon enough occurence that a fix here is not required. The null byte is quite special in and on itself and if somebody put it there in the first place for whatever reason they probably don't want to have jupytext.nvim
messing with it.
I'm working with a
ipynb
file that has the literal characters\
and thenn
in it (as part of a LaTeX\neq
macro). When I try to open this file in Neovim, I get the errorError executing lua callback: ...NeovimPackages/start/jupytext-nvim/lua/jupytext/init.lua:97: 'replacement string' item contains newlines
, and then the file is empty.I rerean neovim with
nvim -V10nvim.log linear.ipynb
and searched through the log, and I found this:I'm pretty sure that this is because nvim_buf_set_lines is being passed a table, where each element is supposed to be a line, and thus not have newlines in them. I managed to fix the plugin, and I'll open a PR in a minute