Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: The name is ....... sometimes too broad for a buffer #541

Merged
merged 1 commit into from
Apr 3, 2024
Merged

fix: The name is ....... sometimes too broad for a buffer #541

merged 1 commit into from
Apr 3, 2024

Conversation

abeldekat
Copy link

@abeldekat abeldekat commented Mar 24, 2024

Fixes issue: #540

Related: This PR, regarding tests.

To consider:

  1. Maybe there are more places where something similar happens
  2. Maybe the question "is there a buffer with this exact name" should be asked to harpoon.buffer.lua
  3. I could not get a test going. Perhaps, this is more an e2e test, needing a testdata folder, with 2 files and a harpoon.json

Non-failing test:

it("can handle the same filename in different directories", function()
    local file_one = "/tmp/namespace/init.lua"
    local buf_one = utils.create_file(file_one, { "foo", "bar" }, 1, 0)
    harpoon:list():append()

    local file_two = "/tmp/init.lua"
    local buf_two = utils.create_file(file_two, {
        "baz",
        "qux",
    }, 1, 0)
    harpoon:list():append()

    harpoon:sync()
    local list = harpoon:list()

    eq(list.items, {
        { value = file_one, context = { row = 1, col = 0 } },
        { value = file_two, context = { row = 1, col = 0 } },
    })

    vim.cmd("bwipeout! " .. buf_one)
    vim.cmd("bwipeout! " .. buf_two)

    harpoon:list():select(1)
    eq("/tmp/namespace/init.lua", vim.api.nvim_buf_get_name(0))
    harpoon:list():select(2)
    eq("/tmp/init.lua", vim.api.nvim_buf_get_name(0))
end)

@ThePrimeagen
Copy link
Owner

ThePrimeagen commented Apr 3, 2024

i can merge this, hodl

i hope this cures these weird file issues*

@ThePrimeagen ThePrimeagen merged commit 3d35250 into ThePrimeagen:harpoon2 Apr 3, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants