Atom doesnt open file on single click in tree view


#1

I have to double click to open a file from the treeview. This started happening unexpectedly yesterday.
Yes i know about the ‘Allow pending pane options’ in the settings, and I don’t want that functionality either.

I simply want to be able to click on a file and have it open in my editor, none of this double clicking business.

Anyone know how to make that work?


#2

Yes, I agree. I don’t like ‘Allow pending Pane options’, and the double clicking to open is driving me nuts…
There should be a menu option to enable/disable double clicking.
This has hindered alot of workflows.
Fortunately, there is discussion to add this back. https://github.com/atom/tree-view/pull/804


#3

Nice, good to know, I decided against opening an issue on github for something so trivial. Seems crazy to me that they would not account for this when they made the update for the pending pane feature. Really minor, but so painfully annoying…


#4

Same issue just popped up for me. I really liked the “one-click” functionality. Hoping there’s a way to restore it…


#5

Personally, I couldn’t take it any longer. I downgraded my Atom and disabled ‘auto updating’ for now.
Not sure if that what you want to resort too…


#6

Good idea, I’ll try that!


#7

In the meantime, you can put the following snippet in your init.js. It immediately sends another click event to a file in the tree view when you click on it a single time :slight_smile:

atom.packages.activatePackage('tree-view').then(treeViewPkg => {
  // Get the tree view DOM element.
  var treeView = atom.views.getView(treeViewPkg.mainModule.createView());
  treeView.addEventListener('click', event => {
    var file, custom;
    // Ignore double-clicks or other mouse buttons.
    // Do nothing if it isn't a file that was clicked.
    if (event.detail == 2 || event.button != 0 ||
      !(file = event.target.closest('.file'))) return;
    // Without nextTick() two copies would open,
    // one in pending mode and one in normal mode.
    process.nextTick(() => {
      // Dispatch a double-click event on the file
      // that was clicked.
      custom = new CustomEvent('click', {
        bubbles: true,
        detail: 2,
      });
      file.dispatchEvent(custom);
    });
    // Cancel this event.
    event.stopImmediatePropagation();
  }, true);
});

Or CoffeeScript variant for those with an init.coffee:

atom.packages.activatePackage('tree-view').then treeViewPkg ->
  # Get the tree view DOM element
  treeView = atom.views.getView treeViewPkg.mainModule.createView()
  treeView.addEventListener 'click', event ->
    # Ignore double-clicks or other mouse buttons.
    # Do nothing if it isn't a file that was clicked.
    return if event.detail is 2 or event.button isnt 0 or
      not (file = event.target.closest '.file')
    # Without nextTick() two copies would open,
    # one in pending mode and one in normal mode.
    process.nextTick () ->
      # Dispatch a double-click event on the file
      # that was clicked.
      custom = new CustomEvent 'click',
        bubbles: true
        detail: 2
      file.dispatchEvent custom
    # Cancel this event.
    event.stopImmediatePropagation()
  , true

#8

Or a much simpler alternative, though this one requires you have the Allow Pending Pane Items setting enabled.

atom.workspace.onDidAddPaneItem(({pane}) => pane.setPendingItem(null));

CoffeeScript:

atom.workspace.onDidAddPaneItem ({pane}) -> pane.setPendingItem(null)

#9

Thanks @olmokramer ,
That init.js is great, but I don’t think Atom users should have to “band-aid” a functionality that should be left for the user to decide.
Unfortunately, Having [Allow Pending Pane Items] enabled is even more painful than double clicking. :slight_smile:
Atom users that work very large projects where you have 100 of files in the tree view may require you need to keep panes open on unchanged files for reference. It just defeats the purpose of Atom all together. To be honest that feature should be disabled by default for new or existing Atom users.


#10

There’s nothing stopping you from keeping unchanged files open even with pending pane items enabled. If you double-click on the item in the tree-view, or double-click on the item’s tab, or even just save the file (whether or not any changes have been made), the pending state will be removed.


#11

I updated the PR, but I wanted to make sure the response was posted here as well:

Upon reviewing this with the team, we have decided that we are no longer going to directly support single-click-to-open without the Allow Pending Pane Items feature being enabled. I’ve made certain that the dev team has heard all the frustration from the community about things being changed without notification. We don’t like frustrating or angering the people that use Atom and this was a hard decision between frustrating some current users and having Atom continue to be jarring for people coming over from other editors.

If you want single-click-to-open (without Allow Pending Pane Items) in your Atom editor, the fantastic @olmokramer has come up with a workaround that he describes here:

Atom doesnt open file on single click in tree view

Again, we regret that this has caused frustration for people. We do think this is the right decision for the long-term usability and supportability of Atom.

Thanks @Alhadis for the work you put in here and starting the discussion!


#12

Ok, I’ve wrapped my fix inside a package: single-click-open. In addition to opening files with a single click from the tree view, it also removes the double click on the search results in the project-find results view :slight_smile:


#13

…and we are back to double clicking everything. I’m still curious to know why the workflow with opening files, panes, etc… was drastically changed and resorting to installing additive packages or making modifications?

@olmokramer
Nice job and Thank You :slight_smile:


#14

I, for one, am on the opposite side of the fence as most of you guys. I hated the single click to open files. There are times when I would like to select multiple files by ctrl + clicking on them without opening them.

I believe the best solution would be to have a setting in the tree view package for single click open. Probably have it off by default as to not jar people coming from other editors as @leedohm mentioned


Is there some type of file preview?
#15

Installed the single-click-open. but it’s still opening a tab for it. How do I get it so single click in tree view opens the file to view, but does not create a tab for it? I’d only want tab created if edited or if file is double clicked in the treeview

Thanks.


#16

There isn’t a way for Atom to not create a tab for any file that’s opened. There are “pending pane items” (formerly called “pending tabs” or “temporary tabs”) where Atom will only allow one “pending pane item” to be open at a time, very similar to Sublime’s single tabless file … there’s just a tab over it.

If you want this functionality, you can uninstall the single-click-open package and check “Allow Pending Pane Items” in the Core Settings:


Is there some type of file preview?
#17

Thanks for the clarification (and screenshot), I see how the temp tab works now and tried it out myself more observantly.

I jump between project files a lot, which leaves a TON of tabs at the top, making it close to useless for using the tabs to go between files efficiently. I wonder if there could be an option for setting a limit to the # of permanent tabs, and it will drop off the “oldest” permanent tab once the limit is hit and its needing to open a new permanent tab That would help keep my tabs from getting out of control…


#18

Have you seen the tidy-tabs package?


#19

no, I hadn’t. Big thanks. exactly what I needed.


#20

There are many problems with the usability of pending pane items. Perhaps the biggest is the fact that they are nearly indistinguishable from normal tabs. Most of the time I’m not looking at the actual tab at all because it’s not relevant to my work at hand. In fact I rarely ever look at the tab bar because I use Ctrl-Tab to move back and forth between open files, and I like to keep a lot of tabs open so I don’t find it particularly useful.

But the thing I’m confused about is what is the real benefit of a pending pane item? Why does this feature even exist? Reducing memory usage? Keeping the tab bar clean? I guess if that’s the case then I suspect this argument is really divided into two camps: those who delete or mark every email in their inbox as read and those that let their unread messages accumulate. I’m definitely of the latter camp. To me there are simply the files that I have been working on recently. I don’t think of them as being open or closed, or permanent or pending. So to me, pending pane items are just tabs that will unexpectedly close themselves at inconvenient times and break my mental locus of attention, not to mention the temporal locality of what I was just doing.

Now it honestly wouldn’t be so bad if those pending tabs still appeared in my Ctrl-Tab list so I can tab back to them if I want to, even if they just reopened as “pending” tabs again and closed when I tabbed away. The problem is they are just gone and I have to do all the work of locating and opening them up all over again.

When I click a file in the side bar to check something, Ctrl-Tab to another file to make some edits and Ctrl-Tab back only to find that tab has vanished, talk about jarring! So now I am forced to think about more things when working in Atom: do I want to actually open a file so I can come back to it again or do I want to “preview” it in a temporary state? Forcing me to think about and answer that question before I even open the file is usability friction.

Thankfully pending pane items can be disabled. So that’s good news. Now I get that some people prefer to double-click to open files. But what I don’t get is why we can’t still single-click to open a file without pending pane items enabled.

All that said, I only complain because I love Atom and the things it gets wrong seem so much worse because there are so few of them.