willothy / nvim-cokeline

:nose: A Neovim bufferline for people with addictive personalities
MIT License
550 stars 38 forks source link

[bug]: about the mouse drag #207

Open FlameTornado10 opened 4 months ago

FlameTornado10 commented 4 months ago

When first drag a random buffer, the reordering works fine. But after one successful reordering, if I choose to drag another buffer, the one that get reordered is not the one I choose latest, but the one that get reordered before. See as this file. Screen Recording - Made with FlexClip.webm

FlameTornado10 commented 4 months ago

This one is clearer. second_video.webm

FlameTornado10 commented 4 months ago

Also, I check the code about mouse drag and figure out one way to handle this. in the function on_drag in nvim-cokeline/lua/cokerline/hover.lua, change

    if M.dragging() == current.bufnr or not M.dragging() then
      M.set_dragging(current.bufnr)
      return
    end

    -- dragged buffer
    local dragged_buf = buffers.get_buffer(M.dragging())

to

    if M.dragging() == current.bufnr or not M.dragging() then
      M.set_dragging(vim.api.nvim_get_current_buf())
      return
    end

    -- dragged buffer
    local dragged_buf = buffers.get_buffer(vim.api.nvim_get_current_buf())

seems to eliminate this bug.