@ 261105.2

260206.2 · 697176246c6296f083c87740cd7c9e9ad2432902

fix(preview): parse bufnr from loaded path

reading declarations

lua/fzf-lua/path.lua

@@ -528,12 +528,19 @@ function M.entry_to_file(entry, opts, force_uri)       end     end   end+  local bufname   local terminal   if bufnr then     terminal = utils.is_term_buffer(bufnr)     if terminal then       file, line = stripped:match("([^:]+):(%d+)")     end+  elseif file and #file > 0 then -- get bufnr from give path+    local buf = vim.fn.bufnr(file)+    if buf ~= -1 and vim.api.nvim_buf_get_name(buf) == file then+      bufnr = buf+      bufname = file+    end   end   if opts.path_shorten and not M.is_uri(stripped) then     file = M.lengthen(file)@@ -542,8 +549,8 @@ function M.entry_to_file(entry, opts, force_uri)   return {     stripped = stripped,     bufnr    = bufnr,-    bufname  = bufnr and vim.api.nvim_buf_is_valid(bufnr)-        and vim.api.nvim_buf_get_name(bufnr),+    bufname  = bufname or (bufnr and vim.api.nvim_buf_is_valid(bufnr)+      and vim.api.nvim_buf_get_name(bufnr) or nil),     terminal = terminal,     path     = file,     line     = utils.tointeger(type(opts.line_query) == "function" and

tests/path_spec.lua

@@ -464,5 +464,22 @@ describe("Testing path module", function()       eq(path.entry_to_file("file:///tmp/test.txt:5:6", {}, false), r)       eq(path.entry_to_file("file:///tmp/test.txt:5:6", {}, true), r)     end)++    it("parse loaded path", function()+      helpers.SKIP_IF_MAC()+      if helpers.IS_WIN() then helpers.SKIP_IF_NOT_NIGHTLY() end+      local r = {}+      vim.cmd [[bwipe]]+      vim.cmd.edit("/tmp/foo:bar.txt")+      local bufname = "/tmp/foo:bar.txt"+      eq(path.entry_to_file("/tmp/foo:bar.txt", r), {+        col = 0,+        line = 0,+        stripped = bufname,+        path = bufname,+        bufnr = vim.fn.bufnr(),+        bufname = helpers.IS_MAC() and vim.fs.joinpath("/private", bufname) or bufname,+      })+    end)   end) end)

tests/screenshots/tests-actions_spec.lua---actions---vimcmd---1-+-args-{-'drop'-}

@@ -13,7 +13,7 @@ 12|d/or se│                                                 │       13|copies │                                                 │Softwa 14|re is  ╰─────────────────────────────────────────────────╯      -15|furnish╭──────────────────── LICENSE ────────────────────╮      +15|furnish╭──────────────── buf 1: LICENSE ─────────────────╮       16|       │  1 MIT License                                          17|The abo│  2                                               l be i 18|ncluded│  3 Copyright (c) 2021 iBhagwan                  │      

tests/screenshots/tests-actions_spec.lua---actions---vimcmd---1-+-args-{-'file_edit'-}

@@ -13,7 +13,7 @@ 12|d/or se│                                                 │       13|copies │                                                 │Softwa 14|re is  ╰─────────────────────────────────────────────────╯      -15|furnish╭──────────────────── LICENSE ────────────────────╮      +15|furnish╭──────────────── buf 6: LICENSE ─────────────────╮       16|       │  1 MIT License                                          17|The abo│  2                                               l be i 18|ncluded│  3 Copyright (c) 2021 iBhagwan                  │      

tests/screenshots/tests-actions_spec.lua---actions---vimcmd---1-+-args-{-'file_open_in_background'-}

@@ -13,7 +13,7 @@ 12|~      │                                                 │       13|~      │                                                 │       14|~      ╰─────────────────────────────────────────────────╯      -15|~      ╭──────────────────── LICENSE ────────────────────╮      +15|~      ╭──────────────── buf 6: LICENSE ─────────────────╮       16|~      │  1 MIT License                                          17|~      │  2                                                      18|~      │  3 Copyright (c) 2021 iBhagwan                  │      

tests/screenshots/tests-actions_spec.lua---actions---vimcmd---1-+-args-{-'file_split'-}

@@ -13,7 +13,7 @@ 12|LICENSE│                                                 │   Top 13|       │                                                 │       14|~      ╰─────────────────────────────────────────────────╯      -15|~      ╭──────────────────── LICENSE ────────────────────╮      +15|~      ╭──────────────── buf 6: LICENSE ─────────────────╮       16|~      │  1 MIT License                                          17|~      │  2                                                      18|~      │  3 Copyright (c) 2021 iBhagwan                  │      

tests/screenshots/tests-actions_spec.lua---actions---vimcmd---1-+-args-{-'file_tabedit'-}

@@ -13,7 +13,7 @@ 12|to use,│                                                 │se, an 13|d/or se│                                                 │       14|copies ╰─────────────────────────────────────────────────╯Softwa-15|re is  ╭──────────────────── LICENSE ────────────────────╮      +15|re is  ╭──────────────── buf 7: LICENSE ─────────────────╮       16|furnish│  1 MIT License                                          17|       │  2                                                      18|The abo│  3 Copyright (c) 2021 iBhagwan                  │l be i

tests/screenshots/tests-actions_spec.lua---actions---vimcmd---1-+-args-{-'file_vsplit'-}

@@ -13,7 +13,7 @@ 12|ion, in│                                                 │       13|n the r│                                                 │       14|to use,╰─────────────────────────────────────────────────╯      -15|lish, d╭──────────────────── LICENSE ────────────────────╮      +15|lish, d╭──────────────── buf 6: LICENSE ─────────────────╮       16|d/or se│  1 MIT License                                          17|copies │  2                                                      18|ermit p│  3 Copyright (c) 2021 iBhagwan                  │