Repository navigation
Preview mode - #2205
Preview mode#2205dcunited08 wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
What do you think about getting rid of the obj parameter? Then lines 208 and 209 could look like this
@subscribe @buffer, "contents-modified", (modified) => @disablePreview() if modified
@subscribe @buffer, "saved" => @disablePreview()There was a problem hiding this comment.
That would work, do you want me to change it or will this go in as shown above?
There was a problem hiding this comment.
It would be great if you could make the change on your preview_mode branch 😄
There was a problem hiding this comment.
I made the recommended changes.
|
This is pretty cool @dcunited08, I'm excited to merge it! It will need some editor specs to make sure it covers all the edge cases. This will close atom/tree-view#3 |
|
This is really great! It'll be nice to have a preview mode 👍 I was wondering if it was possible to also add a Edit: Ignore my comment, I just forgot that the tabs was actually handled by another package, and it seems there's already a PR opened for that. I guess it's a just a matter of coordination. |
|
I think I found a few unexpected behaviors that I need to work out. @abe33 it would be good to designate preview from standard editors. |
…r closePreview() and fixed some code review changes
|
I added some specs to editor-spec but I am unsure of how to run them. Please advise. |
|
@dcunited08 Using |
|
@abe33 Thanks, I ran it twice and it froze up both times on autosave. Not sure if that is expected behavior at this point. @probablycorey Is there anything else you would like to see? |
|
This behavior feels odd:
When |
|
@probablycorey perhaps it would make better sense to disable the preview mode for the editor by default but enable it via a flag from tree-view. It would require a change to that repo as well but may be the best option. |
|
Regarding how ST behaves on AFAIK the only case where an editor is opened in preview mode with a tab is when clicking on an entry in the tree view. And you really open it trough double-click. If I were to choose which version I prefer I'd say that I would love having the file preview when the search file panel is on. But pressing Enter should open the selected file, not just opening a preview (with several panes side by side, I often open many other files as reference, and I don't expect these files to be closed when opening another file). As for the tree view, I haven't test what your current version does but if it opens all files in preview mode I'm personally OK with that. Having a real opening on double-click could be useful for ST users wanting to switch but I don't see that as a must-have. |
|
@dcunited08 listed the following methods of opening a file in the topic on Discuss:
It sounds like what is being proposed are implicit methods of opening or previewing a file. Personally, I think that making all paths use the same functionality would be the least confusing for new users, but I can see the merits of separating them out. So what it sounds like the best approach suggested so far is:
One edge case, Cmd+B browses files ... but only already open ones. If I execute the following steps:
Should it match the file from step 2 as it is a buffer, even if it is in preview mode. Or should it only match the file from step 1? |
|
I like @lee-dohm's proposal. For the first pass I might ignore restoring previewed files, unless it doesn't require much extra code. For the |
|
Another interesting example of this is Visual Studio's preview tab |
|
👍 @lee-dohm and @dcunited08 The reasoning behind files preview seems really solid to me. As for the @probablycorey The VS example is quite interesting indeed, I was thinking something alike for the panes, having kind of |
|
@abe33 Even when you allow something as a setting, you still need a default. I like the idea of the auto-closing pane. Perhaps you should open a feature request for it, @abe33? Personally, I think that Cmd+B should find both open buffers and preview buffers. I think we should not implement a setting for it at first and see what people think. |
|
@lee-dohm @abe33 @probablycorey A few more thoughts on this:
|
|
@dcunited08 Re: Item 1 - If we're all in agreement that single-click on the tree is the only method of previewing (since the Cmd+T behavior support isn't there), why does there need to be a setting? Do we really think anyone is going to use the setting or are you suggesting putting it in just in case? @probablycorey Do the metrics collected track what settings people use and how? If so, can that information be made public to help guide the future development of Atom? If not, can that be added? (And then made public, of course, 😆) |
|
@lee-dohm Sure, I'll have to find some time to dig this auto-closing pane feature. But I don't know yet when it'll be. @dcunited08 Re: Item 2 - Yes, I also think this should be a separate feature, there's already a bit of delay before a buffer is actually rendered on screen, so I don't see how it can be done without impacting the search behavior. @dcunited08 Re: Item 3 - If you want to ignore restoration of preview editors on restart can't you just prevent their serialization by returning |
|
@lee-dohm I wasn't sure we were all in agreement, I am fine with that functionality (tree-view single-click only). @abe33 if there are no known issues with returning null, I'll do it @probablycorey ? |
|
@dcunited08 if the serialization happens automatically I'm happy to leave that in, even if it doesn't remember if it was a preview pane after deserialization. @lee-dohm the metrics don't track individual settings, they are incredibly generic right now. |
|
Until this gets merged in...: |
|
Update: I am continuing to work on this but I am running into other oddities about closing of editors that I haven't ran into until now so I am taking it slow as it seems other items are being changed and I'll let those settle down. |
|
Oops, didn't mean to close ;) |
|
@dcunited08 if you need, refer to that package there.. i've got it working to open temp tabs, and recently (v.0.2.3) got it working to double click the file to open it permanently 👍 |
|
@dcunited08 do you need help doing this? |
|
@probablycorey I feel like this is more elegant anyway since it does not alter the atom/atom API in any way and just modifies the packages that profit directly from it! |
|
@maschs Sounds like a good approach. |
|
@maschs Sorry, I haven't had any time to look at this feel free to grab the code and run with it. My day job pushed Atom to the back burner for me. |
|
My own implementation of this is here: Preview Tabs. It's based on events, and doesn't require any modifications to the tree or tab views. |
|
This looks a lot cleaner than my sublime-tabs package.. nice work. Sublime-Tabs will extend the previously existing tabs and tree view package, but this will just listen in on the events, without any extending of packages.. I like it! |
|
Thanks, @ddavison. I got a lot of use out of your package, and got inspired by it to try my hand at writing one. |
This replicates Sublime Text's semi-transient editor. It the user enables Preview Mode in settings (disabled by default) they can then quickly open files with a new open closing the last one unless they edit or save the file. Then the editor leaves preview mode and is permeant in the workspace until the user closes the tab. Please let me know anything I'm missing.