-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: can toggle help menu with
<f1>
key in the yazi window (#275)
When yazi is open, you can now press `<f1>` to show a help menu with all the keybindings. This is useful for new users who are not yet familiar with the keybindings.
- Loading branch information
1 parent
3a55693
commit cc65bb5
Showing
7 changed files
with
130 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import assert = require("assert") | ||
import { startNeovimWithYa } from "./using-ya-to-read-events/startNeovimWithYa" | ||
|
||
describe("the help menu", () => { | ||
it("can show help with a keymap", () => { | ||
cy.visit("http://localhost:5173") | ||
startNeovimWithYa({ | ||
startupScriptModifications: ["modify_yazi_config_and_set_help_key.lua"], | ||
}).then((dir) => { | ||
// wait until text on the start screen is visible | ||
cy.contains("If you see this text, Neovim is ready!") | ||
|
||
// open yazi and wait for it to load | ||
cy.typeIntoTerminal("{upArrow}") | ||
cy.contains(dir.contents["test-setup.lua"].name) | ||
|
||
cy.typeIntoTerminal("{del}") | ||
cy.contains("yazi.nvim help") | ||
|
||
// the config for this test overrides the help key to be <del>. Make sure | ||
// overrides are shown | ||
cy.contains("<del> - show this help") | ||
|
||
// the version of yazi.nvim should be shown | ||
cy.readFile("../.release-please-manifest.json").then( | ||
(yaziNvimManifest: unknown) => { | ||
assert(typeof yaziNvimManifest === "object") | ||
assert(yaziNvimManifest) | ||
assert("." in yaziNvimManifest) | ||
assert(typeof yaziNvimManifest["."] === "string") | ||
cy.contains(`version ${yaziNvimManifest["."]}`) | ||
}, | ||
) | ||
|
||
// The help buffer must not be modifiable. Don't assert the text as it | ||
// may be translated to the developer's own language. | ||
cy.typeIntoTerminal("i") | ||
cy.contains("E21") // Cannot make changes, 'modifiable' is off | ||
|
||
// close the help buffer. It should enable insert mode in the yazi buffer. | ||
cy.typeIntoTerminal("q") | ||
cy.contains("yazi.nvim help").should("not.exist") | ||
|
||
// it should now be possible to close yazi, since it's in insert mode | ||
// and ready to accept commands | ||
cy.contains(dir.contents["test-setup.lua"].name) | ||
cy.typeIntoTerminal("q") | ||
cy.contains(dir.contents["test-setup.lua"].name).should("not.exist") | ||
}) | ||
}) | ||
}) |
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
14 changes: 14 additions & 0 deletions
14
...ation-tests/test-environment/config-modifications/modify_yazi_config_and_set_help_key.lua
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
---@module "yazi" | ||
|
||
-- The reason to set a different yazi.nvim help key is that Cypress, the | ||
-- current test runner, does not natively support function keys such as <f1> | ||
-- https://docs.cypress.io/api/commands/type#Arguments | ||
|
||
require('yazi').setup( | ||
---@type YaziConfig | ||
{ | ||
keymaps = { | ||
show_help = '<del>', | ||
}, | ||
} | ||
) |
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