-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openers)!: multiple files are opened as buffers by default
BREAKING CHANGE: when multiple files were selected in yazi, the previous behaviour was to open them as items in the quickfix list. This has been changed to open them as buffers instead. The previous behaviour can be restored by setting `config.hooks.yazi_opened_multiple_files` to `openers.send_files_to_quickfix_list`. ```lua -- Example for lazy.nvim: -- ---@type LazySpec { 'mikavilpas/yazi.nvim', ---@type YaziConfig opts = { ---@diagnostic disable-next-line: missing-fields hooks = { yazi_opened_multiple_files = function(chosen_files) require("yazi.openers").send_files_to_quickfix_list(chosen_files) end, }, }, } ``` ✨feat(`openers`): New opener `open_multiple_files()` is now the default value for `config.hooks.yazi_opened_multiple_files`. Co-authored-by: Mika Vilpas <[email protected]>
- Loading branch information
1 parent
eb12317
commit 5cd3ad7
Showing
8 changed files
with
65 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,6 @@ jobs: | |
name: prettier | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
ref: ${{ github.head_ref }} | ||
- uses: actions/[email protected] | ||
with: | ||
node-version-file: .nvmrc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,39 @@ describe('the default configuration', function() | |
end | ||
end) | ||
|
||
local plenary_path = require('plenary.path') | ||
local test_file_path = plenary_path:new(vim.fn.getcwd(), 'test-file.txt') | ||
|
||
it('opens multiple files in buffers by default', function() | ||
local config = require('yazi.config').default() | ||
local chosen_files = { '/abc/test-file.txt', '/abc/test-file2.txt' } | ||
|
||
config.hooks.yazi_opened_multiple_files( | ||
chosen_files, | ||
config, | ||
test_file_path | ||
) | ||
|
||
local buffers = vim.api.nvim_list_bufs() | ||
|
||
assert.equals(2, #buffers) | ||
assert.equals('/abc/test-file.txt', vim.api.nvim_buf_get_name(buffers[1])) | ||
assert.equals('/abc/test-file2.txt', vim.api.nvim_buf_get_name(buffers[2])) | ||
end) | ||
|
||
it('can display multiple files in the quickfix list', function() | ||
local config = require('yazi.config').default() | ||
config.hooks.yazi_opened_multiple_files = | ||
require('yazi.openers').send_files_to_quickfix_list | ||
|
||
-- include problematic characters in the file names to preserve their behaviour | ||
local chosen_files = { '/abc/[email protected]', '/abc/test-file2.txt' } | ||
|
||
config.hooks.yazi_opened_multiple_files(chosen_files, config) | ||
config.hooks.yazi_opened_multiple_files( | ||
chosen_files, | ||
config, | ||
test_file_path | ||
) | ||
|
||
local quickfix_list = vim.fn.getqflist() | ||
|
||
|
5cd3ad7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new behavior doesn't seem to play well with
bufferline.nvim
for me.When selecting multiple files and pressing
Enter
,bufferline
doesn't show up, as if there were only one buffer.:buffers
does show all the files I opened in different buffers.With this hook,
bufferline
displays all buffers normally:5cd3ad7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm can you open an isuse for this? I tried to reproduce it but I don't get the same behaviour - for me, bufferline does show up.
5cd3ad7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't reproduce with a minimal
repro.lua
either, only with my Neovim config. Not sure what's going on. Opening files fromNeotree
creates distinct buffers frombufferline
as expected.Edit: I'll experiment and let you know.