NotebookNavigator.nvim icon indicating copy to clipboard operation
NotebookNavigator.nvim copied to clipboard

run_all_cell error: Invalid 'replacement string' item

Open IgorRain opened this issue 8 months ago • 3 comments

I configured Molten as my REPL. When I call run_cell() or run_and_move() everything works as expected, but run_all_cells() fails with an error:

Error executing lua .../NotebookNavigator.nvim/lua/notebook-navigator/repls.lua:50: Invalid 'replacement string' item: expected String, got nil
stack traceback:
	[C]: in function 'nvim_buf_set_lines'
	.../NotebookNavigator.nvim/lua/notebook-navigator/repls.lua:50: in function 'repl'
	...y/NotebookNavigator.nvim/lua/notebook-navigator/core.lua:128: in function 'run_all_cells'
	...y/NotebookNavigator.nvim/lua/notebook-navigator/init.lua:110: in function 'run_all_cells'
	[string ":lua"]:1: in main chunk

My plugin config:

opts = {
  repl_provider = 'molten',
},

IgorRain avatar May 24 '25 17:05 IgorRain

I assume that the problem is in core.lua: in function run_all_cells() on line 128 repl is called with 3 arguments, so this call omits cell_marker argument. In run_cell() on line 106 repl is called with all 4 arguments. The run_cell works in molten because line_count < (end_line + 1) condition (file repls.lua line 49) is false in this case. Iron repl doesn't use cell_marker argument at all. For Molten cell_marker only used in case of running all file.

I hacked a quick fix with drilling cell_marker from init.lua. It kinda solves the problem, but I'm not sure that it's a proper fix and the way how it supposed to work, because in this case a file is treated as one giant cell, so the whole output is packed after last line in a file.

IgorRain avatar May 24 '25 18:05 IgorRain

What do you mean drilling cell_marker from init.llua? @IgorRain

nwpulverizer avatar Jul 10 '25 20:07 nwpulverizer

What do you mean drilling cell_marker from init.llua? @IgorRain

Sorry for long response.

I mean that cell_marker is defined in init.lua and then used in repls.lua. So this argument is required to pass through the whole call chain. Current implementation doesn't do it. But just passing this argument leads to a weird behavior.

IgorRain avatar Aug 04 '25 06:08 IgorRain