Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

nvim_buf_get_lines not working #60

Open
CrossR opened this issue Nov 8, 2019 · 0 comments
Open

nvim_buf_get_lines not working #60

CrossR opened this issue Nov 8, 2019 · 0 comments

Comments

@CrossR
Copy link

CrossR commented Nov 8, 2019

Hey!

I've been messing with this, and hit a weird bug where if I called nvim.api.buf_set_lines, I got back the error pynvim.api.nvim.NvimError: b"object of type 'int' has no len()".

This was when calling it with 0, 0, -1, True.

Looking at the code for nvim_buf_get_lines and set lines, it looks like the first argument buffer is treated as the buffer, rather than the buffer index, as implied by the nvim docs :

Parameters: 
                    {buffer}           Buffer handle, or 0 for current buffer

Or over in

EXT Type	C type					Data
  ------------------------------------------------------------------------
  Buffer	enum value kObjectTypeBuffer		|bufnr()|

I could be entirely wrong, and my code is just working oddly, but if I add in a buffer_contents = vim.buffers[buffer] (or I guess vim.current.buffer for buffer == 0) and then use buffer_contents rather than buffer, the set and get work as expected.

Is that expected, or am I just using the function wrong?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant