diff --git a/lua/yazi/config.lua b/lua/yazi/config.lua index dc05e5e..b426a14 100644 --- a/lua/yazi/config.lua +++ b/lua/yazi/config.lua @@ -48,7 +48,7 @@ function M.default() local filter = directory:make_relative(vim.uv.cwd()) require('grug-far').grug_far({ prefills = { - paths = filter, + paths = filter:gsub(' ', '\\ '), }, }) end, diff --git a/spec/yazi/grug_far_spec.lua b/spec/yazi/grug_far_spec.lua new file mode 100644 index 0000000..ae6e4ce --- /dev/null +++ b/spec/yazi/grug_far_spec.lua @@ -0,0 +1,27 @@ +---@module "plenary.path" + +local assert = require('luassert') +local mock = require('luassert.mock') +local config = require('yazi.config') +local plenary_path = require('plenary.path') + +describe('the grug-far integration (search and replace)', function() + local mock_grug_far = { grug_far = function() end } + + before_each(function() + mock.revert(mock_grug_far) + package.loaded['grug-far'] = mock(mock_grug_far) + end) + + it('opens yazi with the current file selected', function() + local tmp_path = plenary_path:new('/tmp/folder with spaces/') + + config.default().integrations.replace_in_directory(tmp_path) + + assert.spy(mock_grug_far.grug_far).was_called_with({ + prefills = { + paths = '/tmp/folder\\ with\\ spaces', + }, + }) + end) +end)