Skip to content

Commit

Permalink
harpoon select: ask for the bufnr using the exact name
Browse files Browse the repository at this point in the history
  • Loading branch information
abeldekat committed Mar 24, 2024
1 parent a38be6e commit c6446e9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lua/harpoon/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ local Path = require("plenary.path")
local function normalize_path(buf_name, root)
return Path:new(buf_name):make_relative(root)
end
local function to_exact_name(value)
return "^" .. value .. "$"
end

local M = {}
local DEFAULT_LIST = "__harpoon_files"
Expand Down Expand Up @@ -101,11 +104,12 @@ function M.get_default_config()
return
end

local bufnr = vim.fn.bufnr(list_item.value)
local bufnr = vim.fn.bufnr(to_exact_name(list_item.value))
local set_position = false
if bufnr == -1 then
if bufnr == -1 then -- must create a buffer!
set_position = true
bufnr = vim.fn.bufnr(list_item.value, true)
-- bufnr = vim.fn.bufnr(list_item.value, true)
bufnr = vim.fn.bufadd(list_item.value)
end
if not vim.api.nvim_buf_is_loaded(bufnr) then
vim.fn.bufload(bufnr)
Expand Down

0 comments on commit c6446e9

Please sign in to comment.