kndndrj / nvim-dbee

Interactive database client for neovim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CSV yanks only part of the data

oleksandr-oksenenko opened this issue · comments

When yanking a reasonable amount of results (i had 200+) using a CSV formatter only parts of the data appear in the register.

I assume it happens because Go CSV writer uses a buffered writer, which flushes buffered data whenever it reaches a certain threshold (4096 bytes i think), which in turn triggers setreg call on each flush.

I managed to workaround it with a local copy of a plugin using a bytes.Buffer instead of a register as a io.Writer and writing resulting bytes to the register:

func (yo *YankRegisterOutput) Write(result models.Result) error {
    writer := new(bytes.Buffer)
    
    err := yo.formatter.Format(result, writer)
    if err != nil {
        return err
    }

    reg := newRegister(yo.vim)
    _, err = reg.Write(writer.Bytes())

    return err
}

I'm nowhere near a proficient level in Go though, so maybe there's a better solution to this :)

P.S.: Really loving this plugin! Let me know if I can help with anything.

Hi @oleksandr-oksenenko thanks for the observation and a possible fix.

The I'll look into it. I guess something like this might also be the case in other yanked formats

I guess something like this might also be the case in other yanked formats

From my observations it's not, but would be great to double-check anyway.
Thanks!