Skip to content

Commit

Permalink
fix: not being in insert mode when opening a dir from the command line (
Browse files Browse the repository at this point in the history
  • Loading branch information
mikavilpas authored Aug 4, 2024
1 parent b2f8d4b commit c44ad14
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ describe("opening directories", () => {

// yazi should now be visible in the new directory
cy.contains(dir.contents["routes/posts.$postId/route.tsx"].name)

// yazi should now be in insert mode. This means pressing q should exit.
cy.typeIntoTerminal("q")

cy.contains(dir.contents["routes/posts.$postId/route.tsx"].name).should(
"not.exist",
)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ describe("opening directories", () => {

// yazi should now be visible in the new directory
cy.contains(dir.contents["routes/posts.$postId/route.tsx"].name)

// yazi should now be in insert mode. This means pressing q should exit.
cy.typeIntoTerminal("q")

cy.contains(dir.contents["routes/posts.$postId/route.tsx"].name).should(
"not.exist",
)
})
})
})
6 changes: 6 additions & 0 deletions lua/yazi/hijack_netrw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ function M.hijack_netrw(yazi_augroup)

Log:debug(string.format('Opening yazi for directory %s', file))
require('yazi').yazi(M.config, file)

-- HACK: for some reason, the cursor is not in insert mode when opening
-- yazi from the command line with `neovim .`, so just simulate
-- pressing "i" to enter insert mode :) It did nothing when when I
-- tried using vim.cmd('startinsert') or vim.cmd('normal! i')
vim.api.nvim_feedkeys('i', 'n', false)
end)
end
end
Expand Down

0 comments on commit c44ad14

Please sign in to comment.