From c6446e971f1a34c46deee1a22d06049ea2de0603 Mon Sep 17 00:00:00 2001 From: abeldekat Date: Sun, 24 Mar 2024 11:26:29 +0100 Subject: [PATCH] harpoon select: ask for the bufnr using the exact name --- lua/harpoon/config.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lua/harpoon/config.lua b/lua/harpoon/config.lua index a759297..19aae3b 100644 --- a/lua/harpoon/config.lua +++ b/lua/harpoon/config.lua @@ -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" @@ -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)