Skip to content

Commit

Permalink
fix: grug-far integration not being able to search outside of the cwd (
Browse files Browse the repository at this point in the history
…#256)

There was a bug in the grug-far integration (the default search and
replace integration in yazi.nvim) where it was not able to search
outside of the current working directory. This was due to the fact that
the file path to search in was passed in `Files Filter` instead of in
`Flags`, which is the correct place to pass the file path.

MagicDuck/grug-far.nvim#146
  • Loading branch information
mikavilpas authored Jul 25, 2024
1 parent e29f633 commit f446cb8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ describe("integrations to other tools", () => {

// the directory we were in should be prefilled in grug-far.nvim's view
cy.contains("testdirs")
const p = path.join(
dir.rootPathRelativeToTestEnvironmentDir,
"routes",
"**",
)
const p = path.join(dir.rootPathRelativeToTestEnvironmentDir, "routes")
cy.contains(p)

// by default, the focus is on the search field in normal mode. Type
// something in the search field so we can see if results can be found
cy.typeIntoTerminal("ithis")

// maybe we don't want to make too many assertions on code we don't own
// though, so for now we trust that it works in CI, and can verify it
// works locally
})
})
})
9 changes: 6 additions & 3 deletions lua/yazi/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ function M.default()
})
end,
replace_in_directory = function(directory)
-- limit the search to the given path, based on cwd
local filter = directory:joinpath('**'):make_relative(vim.uv.cwd())
-- limit the search to the given path
--
-- `prefills.flags` get passed to ripgrep as is
-- https://github.com/MagicDuck/grug-far.nvim/issues/146
local filter = directory:make_relative(vim.uv.cwd())
require('grug-far').grug_far({
prefills = {
filesFilter = filter,
flags = filter,
},
})
end,
Expand Down

0 comments on commit f446cb8

Please sign in to comment.