Skip to content

Commit

Permalink
fixup! feat: highlight the currently hovered file in yazi (opt-in)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikavilpas committed Jul 12, 2024
1 parent 571ef77 commit cb6d5d6
Showing 1 changed file with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ describe("highlighting the buffer with 'hover' events", () => {
// there are multiple colors. Work around this by matching a substring of the
// text instead of the whole text.

/** HACK in CI, there can be timing issues where the first hover event is
* lost. Right now we work around this by selecting another file first, then
* hovering the desired file.
*/
function hoverAnotherFileToEnsureHoverEventIsReceivedInCI(file: string) {
// select another file (hacky)
cy.typeIntoTerminal("gg")

// select the desired file so that a new hover event is sent
cy.typeIntoTerminal(`/${file}{enter}`)
}

it("can highlight the buffer when hovered", () => {
startNeovimWithYa().then((dir) => {
// wait until text on the start screen is visible
Expand All @@ -26,6 +38,10 @@ describe("highlighting the buffer with 'hover' events", () => {
// start yazi
cy.typeIntoTerminal("{upArrow}")

hoverAnotherFileToEnsureHoverEventIsReceivedInCI(
dir.contents["initial-file.txt"].name,
)

// yazi is shown and adjacent files should be visible now
//
// the current file (initial-file.txt) is highlighted by default when
Expand Down Expand Up @@ -63,6 +79,10 @@ describe("highlighting the buffer with 'hover' events", () => {
// yazi is shown and adjacent files should be visible now
cy.contains(dir.contents["test.lua"].name)

hoverAnotherFileToEnsureHoverEventIsReceivedInCI(
dir.contents["initial-file.txt"].name,
)

// the current file (initial-file.txt) is highlighted by default when
// opening yazi. This should have sent the 'hover' event and caused the
// Neovim window to be shown with a different background color
Expand Down Expand Up @@ -90,15 +110,17 @@ describe("highlighting the buffer with 'hover' events", () => {
.children()
.should("have.css", "background-color", backgroundColors.normal)

const testFile = dir.contents["test.lua"].name
// open an adjacent file and wait for it to be displayed
cy.typeIntoTerminal(
`:vsplit ${dir.rootPath}/${dir.contents["test.lua"].name}{enter}`,
{ delay: 1 },
)
cy.typeIntoTerminal(`:vsplit ${dir.rootPath}/${testFile}{enter}`, {
delay: 1,
})
cy.contains("how to initialize the test environment")

// start yazi - the initial file should be highlighted
cy.typeIntoTerminal("{upArrow}")

hoverAnotherFileToEnsureHoverEventIsReceivedInCI(testFile)
cy.contains("how to initialize the test environment").should(
"have.css",
"background-color",
Expand Down

0 comments on commit cb6d5d6

Please sign in to comment.