atom/tree-view

No Project Tree View When Opening a Single File

trifinbholcombe opened this issue ยท 17 comments

Description

Tree view is not working since the last update. Expected behavior is to see the project tree view of the file opened.

Steps to Reproduce

  1. With either a closed Atom OR opened Atom editor. Open top-level file in project folder.

Expected behavior:
Expected behavior is to see the project tree view with files in the project folder of the file opened.

Actual behavior:

  1. Open top-level file in project folder
  2. No Project Tree view visible for current editable file

Reproduces how often:
100% of the time since last update

Versions

1.36.0 x64

Can confirm.

rsese commented

Thanks for reaching out!

  1. Open top-level file in project folder

This change was intentional for opening single files as of 1.36 for performance reasons detailed in the blog

https://blog.atom.io/2019/04/09/atom-1-36.html#id=%22open-a-single-file-without-its-parent-directory%22

So if you specifically want to open a single file but work in the project as well, you can:

  1. run Application: Add Project Folder after opening the single file
  2. start Atom with the directory of your project and then open the file you want to work on

Just to clarify @trifinbholcombe @omniacode, do you often start Atom to work on projects by opening a single file rather than opening the project directory?

Thanks @rsese, this works.

Re: single file
Yes, working on several projects at once it's pretty quick and efficient. I close the current project Atom window then open new top level file in a new project folder to edit the file as well as open the tree view.

I agree that this is an issue. I often want to open a project by opening a single file. I think the option to not open the tree should be something toggleable. Would really want to see this changed.

I can second this. Would it be possible to add an option for that? Or maybe provide an alternative version?

Ditto, same issue here

rsese commented

We're not currently looking at adding an option for this, we were mainly looking at resolving that long-standing performance problem. There has been discussion about possibly adding a UI element to the tree view to make it easy to add the project folder for the opened file but I can't make any promises about that.

For command line users, there's also an alternate syntax you can use - if you're in a directory where you want to open file a.md, instead of:

atom a.md

You can pass the directory followed by the filename:

atom . a.md

@Mezilsa @ArvinB - do you mainly open single files from your file manager (e.g. Finder on macOS, Windows Explorer on Windows, etc.)?

@rsese
Jep. I mean I COULD change my whole workflow and add each folder at each start of atom, but ...meh, you know and when you just want to make a small change it's easier to just click the file and have the whole folder to work with, espacially for Search and Replace opperations accross multiple files.

This also creates the problem of atom opening new windows every time you open a file instead of adding it to a single window, which is often what is most convenient. Them not having trees on top of having to sort through the windows on my desktop is pretty frustrating.

rsese commented

@ThatBenKraft - just to confirm, it sounds like you also tend to open files from your file manager rather than the command line? And in the case you described, is it partly that sometime you don't necessarily know that you're going to work on multiple files in a project so wouldn't start by opening the directory rather than a single file?

I'm so glad I found this thread. I've been disabling and enabling packages, looking through every setting I could find, trying to figure out why the behavior changed. I must have lost 4-5 hours on this.

My Project pane doesn't show anything, even in safe mode, even if I have multiple files from the same folder open, even if I hit command-\, unless I specifically drop a folder onto it or onto the Atom executable.

I nearly always open files from my file manager. I rarely have a command line open because most of what I do is in client-side javascript.

@rsese - The main issue is that the way I begin to work on a project is by opening a single file, and then usually I would open the rest of the files through the tree. However, now I have to manually open the tree and then manually find the project folder instead of it being done by itself. I would even be fine with the tree needing to be toggled (currently as cmd+\) as long as it finds the path to the project folder for me.

owsky commented

I also wasted a couple hours trying to debug this. I really liked the previous behavior and it was one of the reasons I switched to Atom from VS Code. I hope you'll consider implementing an option.

I would even be fine with the tree needing to be toggled (currently as cmd+) as long as it finds the path to the project folder for me.

Yes, that.

@rsese could you be convinced to revisit this one?

I appreciate it's much later in the year and this issue is seemingly been left as "working as intended".

But as someone who regularly alternates between using a launcher that opens project files for me (single files) and double-clicking on individual source files within Windows Explorer... all I can say is that the the change in 1.36.0 has meant I can't (maybe "won't" is more accurate) use the latest version of Atom.

I appreciate the the launcher I'm thinking of could be altered to invoke "atom {folder} {folder}{filename}" and that works for that single occasion. But closing the file and starting Atom again leaves the treeview that was previously shown. It's not terrible, but just untidy.

All I would be looking for is an option within the treeview package that would optionally revert it's behavior to work the same as it did prior to the change in 1.36.0. Effectively "Open and Index Parent Directory when opening a single file [Yes/No]". I fully understand there would be a performance hit and based on change already being implemented... it should probably be defaulted to "off".

But at least give us the choice.

My only choice right now is to use 1.35.1 and miss out of other useful features (not that I really use Atom to it's full capabilities).

And yes, I'm starting to edit my whole project by starting opening a single file. Maybe I only end up editing that single file... or maybe (as used to be possible), I use the treeview to switch to another file that is part of my project.

My other two posts to Atom and RenPy support forums... as background...
(posted before I knew I this issue reporting existed).

To anyone missing TreeView when opening a single file... someone much more competent than I figured out a workaround for releases 1.36.0 of Atom and later.

From the main Atom screen... Use "File" --> "Init script...". This will edit Atom's "init.coffee" file.

Then add the following code:

atom.packages.onDidActivateInitialPackages ->
  return unless (atom.project.getPaths().length < 1)
  return unless path = atom.workspace.getActiveTextEditor().getPath()
  atom.project.addPath(path)

Credit goes to use Snoop, who provided this answer here:
https://discuss.atom.io/t/treeview-not-populating-when-loading-a-single-file/69757/15

All I can say is that this initialization script change seems to work for me using Windows 7 64bit. Other operating systems... other versions of Windows... Your mileage may vary. I might find it doesn't work later But right now, I'm happy.

Which is not to say I still wouldn't appreciate an option for the TreeView package that would allow the same functionality so that the same effect could be achieved by creating a custom .atom folder when installing Atom through the RenPy UI (which currently installs 0.34.0).

Hi I'm trying to use the Compare Files Package and when I run it says to select two files from the tree view. How do I do this without the tree view?