Treemacs: Bug: Single mouse click inside scroll-margin causes file to open

Created on 23 Nov 2020  路  3Comments  路  Source: Alexander-Miller/treemacs

I have (setq scroll-margin 10) and if I single click an item in the tree inside this margin (either 10 lines in from the top or bottom) the tree scrolls to make the selected item more than 10 lines away from the top or bottom margins (fine) but also opens the file as if I have double clicked or hit RET.

The scroll behaviour is fine and perhaps expected but I see no reason why the file should also open.

Mouse Interface QuestioDiscussion

All 3 comments

I can confirm this is happening and the cause is treemacs' mouse dragging support. It looks like emacs thinks the mouse click in combination with a margin-forced scroll means you have dragged the mouse and thus calls treemacs-dragleftclick-action.

I don't think this is something that can be reasonably worked around, so there's 2 things you can do here:

  • Set the local scroll-margin to 0. I don't think the auto-scrolling would be very pleasant even if it didn't open files.
  • Disable treemacs' mouse drag support with (fset #'treemacs-dragleftclick-action #'ignore)

Thanks @Alexander-Miller. Do you know how I would set scroll-margin just for Treemacs?

You can do it in a mode hook like this:

(add-hook 'treemacs-mode-hook
          (defun set-local-scroll-margin ()
            (setq-local scroll-margin 0)))
Was this page helpful?
0 / 5 - 0 ratings

Related issues

kenkangxgwe picture kenkangxgwe  路  9Comments

ianpan870102 picture ianpan870102  路  7Comments

lromor picture lromor  路  6Comments

simurgh9 picture simurgh9  路  3Comments

FieryCod picture FieryCod  路  4Comments