-
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.
fix: close the floating terminal if it loses focus (#269)
* refactor(tests): add mouse click support * fix: close the floating terminal if it loses focus The floating terminal that shows yazi running can lose focus when e.g. clicked outside of. This commit adds an autocmd that closes the floating terminal in these cases. The reason for this is that it's inconvenient to navigate back to the floating terminal to close it manually. Even if you did this, it was in normal mode - not insert mode which is typically what you want to be in when you're using yazi.
- Loading branch information
1 parent
0099e63
commit c9ebbf6
Showing
9 changed files
with
97 additions
and
4 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
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,17 @@ | ||
// Function to parse mouse events | ||
// https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Button-event-tracking | ||
export function validateMouseEvent(data: string): string | undefined { | ||
const match = /\x1b\[<(\d+);(\d+);(\d+)([mM])/.exec(data) | ||
if (match) { | ||
const buttonCode = parseInt(match[1], 10) | ||
const column = parseInt(match[2], 10) | ||
const row = parseInt(match[3], 10) | ||
const isRelease = match[4] === "m" | ||
|
||
console.log( | ||
`Mouse event: buttonCode=${buttonCode}, column=${column}, row=${row}, isRelease=${isRelease}`, | ||
) | ||
|
||
return data | ||
} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
integration-tests/cypress/e2e/using-ya-to-read-events/mouse.cy.ts
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,28 @@ | ||
import { startNeovimWithYa } from "./startNeovimWithYa" | ||
|
||
describe("mouse support", () => { | ||
beforeEach(() => { | ||
cy.visit("http://localhost:5173") | ||
}) | ||
|
||
it("can use grug-far.nvim to search and replace in the cwd", () => { | ||
startNeovimWithYa().then((dir) => { | ||
// wait until text on the start screen is visible | ||
cy.contains("If you see this text, Neovim is ready!") | ||
|
||
// open yazi | ||
cy.typeIntoTerminal("{upArrow}") | ||
|
||
// yazi should be showing adjacent files | ||
cy.contains(dir.contents["test.lua"].name) | ||
|
||
// click outside of the yazi floating window. This should close it | ||
// because it's designed to close when it loses focus | ||
cy.contains("-- TERMINAL --").click() | ||
|
||
// clicking outside of the yazi window should close it, after which | ||
// Neovim should not be showing the TERMINAL buffer any longer | ||
cy.contains("-- TERMINAL --").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
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