Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

double click option for open files #1884

Open
sergDash opened this issue Sep 24, 2024 · 4 comments
Open

double click option for open files #1884

sergDash opened this issue Sep 24, 2024 · 4 comments

Comments

@sergDash
Copy link

photo_2024-09-25_01-00-55

@Guldoman
Copy link
Member

You can do that by rebinding some treeview commands.
For example add this to your user module:

keymap.add({
  ["2lclick"] = "treeview:select-and-open",
  ["1lclick"] = "treeview:select"
})

@sergDash
Copy link
Author

Single clicks on directories are quite satisfactory. The problem is that random clicks on files open them. It seems to me that such code will also open directories with a double click.

@Guldoman
Copy link
Member

Yeah, you could create a new command to do that:

local TreeView = require "plugins.treeview"
local command = require "core.command"

command.add(function()
  return core.active_view == TreeView, core.active_view
end, {
  ["custom-treeview:select-file-or-open-dir"] = function(view)
    if view.hovered_item and view.hovered_item.type == "dir" then
      command.perform("treeview:select-and-open")
    else
      command.perform("treeview:select")
    end
  end
})

keymap.add({
  ["2lclick"] = "treeview:select-and-open",
  ["1lclick"] = "custom-treeview:select-file-or-open-dir"
})

@sergDash
Copy link
Author

Yes, great, that works too. It would be great to write it into the user module so that others could quickly find this knowledge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants