Repository navigation
Fix preview tabs #9165
Description
From @benogle on October 15, 2015 22:46
There have been a lot of issues created related to preview tabs. It seems like nearly all of these issues could be solved by a couple things:
- Create all tabs as 'permanent' by default and only open in a preview tab in a couple cases:
- Single clicking in the tree-view
- Single clicking in project find results pane
- And eventually (when open files is suuuper fast) opening preview tabs when arrowing through the fuzzy finder
- Close the preview tab when it loses focus
The issues
- Files opened from external source should not be temporary tabs#170
- [Enhancement] Do not preview direct-opened tabs tabs#206
- Keep preview open whenever the pane is double-clicked tabs#202
- Preview tab should close when it loses focus tabs#196
- Better indicate preview tab tabs#180
- Double clicking on file in Tree view to open permanent tab not working if containing folder is a symlink tabs#173
- Files opened from external source should not be temporary tabs#170
- Files opened via fuzzy finder should not be temporary tabs#164
- key bindings doesn't work on temporary tabs tabs#207
- Tabs restoring with Preview Tabs enabled. tabs#163
- Setting To Open Permanently When Using Preview Tabs fuzzy-finder#108
The short term approach
Currently preview-tabs is implemented entirely in the tabs package. When a new pane item is opened, the tabs package closes the old pane item associated with the preview tab, and creates a new tab. So atom core (or other packages) has no idea that there are preview tabs. This is kind of crappy as
- There are hacks in the tabs package to handle things like double clicking in the tree view to make a tab permanent.
- There is no way for other packages to open preview tabs, or even know about them without accessing the tabs package
- Along the same lines, a couple folks want an API, and the only way to provide an API would be to add a service or hack to the tabs package.
That said, we could probably do a quick fix to change the default behavior to open a 'permanent' tab, and hack the other packages to open preview tabs in the exceptions listed above.
The long term approach
A cleaner and more robust approach would be to bake the notion of a preview pane item into atom core. Packages could then decide to open preview items if they so choose. Then there would be no hacks: tree-view and the find results could open a preview item on single click; tabs could watch for preview items and have them all share one tab element.
@nathansobo @maxbrunsfeld not sure how much effort this longer term approach would be. Can you estimate how long it would take to add a new option to open() indicating the notion of a preview pane-item + related events?
cc @atom/feedback
Copied from original issue: atom/tabs#218
Activity
benogle commentedon Oct 15, 2015
Moved to core cause the API is a core concern, and this discussion touches packages other than tabs.
nathansobo commentedon Oct 15, 2015
Probably wouldn't be a huge investment to add this API.
Here's my initial thoughts.
We add a new method,
Pane.prototype.previewItem. When called, this method notifiesonDidAddItemlisteners with a newpreviewproperty on the event object set to true. The preview item is removed if the pane receives and then loses focus. The preview item is replaced ifpreviewItemis called again with another item. The preview item "graduates" to a normal item ifaddItemis called with the same item or the item implementsonDidChangeModifiedand its status changes totrue.We'll need to add a new event subscription method so packages can track when preview items become normal items. I'm still struggling with the name of this method.
onDidStopPreviewingItemDid we stop previewing because the item got removed or because the item is done being previewed.onDidMakeItemPermanentI want a good verb instead "make" plus an adjective. Plus the item really isn't "permanent". It can be removed. It's just a bit more permanent than the preview item.onDidConfirmPreviewItemVague verb.onDidRatifyPreviewItemSounds like a trade agreement.onDidGraduatePreviewItemonDidAdoptPreviewItemSomeone come up with a better idea for a name. What happens when a preview item becomes a normal item. What's that called? What's the verb for that?
billybonks commentedon Oct 25, 2015
onDidSelectPreviewItempreview item upgradedonDidOpenPreviewItemoronDidChangePrewviewItemchanged preview itemnathansobo commentedon Oct 25, 2015
Now I'm liking
onDidRetainPreviewedItemto describe the moment where a preview item is converted into a regular item.billybonks commentedon Oct 25, 2015
I like the verb but prefer the present tense
onDidRetainPreviewItemyou cant retain it if you didn't preview it.one issue i have with your rough api description is:
in order to do this, the preview pane needs be given focus when it is opened. this wouldn't work well for this feature:↕️ , opens a preview pane whenever a item is selected.
Navigating the treeview with
etc
with the former mentioned api behaviour, the workflow would be:
adamreisnz commentedon Nov 10, 2015
Glad to see this being progressed. Has there been a definite decision on whether the "short term approach" is going to be implemented?
nathansobo commentedon Nov 10, 2015
Adding these core APIs and using them in select bundled packages is pretty near term on the roadmap.
adamreisnz commentedon Nov 10, 2015
Great, thanks
paulpflug commentedon Dec 17, 2015
Why is it added to the pane? Is there a use case other than previewing in a texteditor?
This is what I would need:
kuychaco commentedon Jan 6, 2016
@benogle curious to know why you want single clicking in project find results pane to result in a preview tab. For comparison, Sublime simply opens a permanent tab for this case
adamreisnz commentedon Jan 6, 2016
@kuychaco sometimes I search for some code that I know I wrote, but unsure in what specific file. In that case it's useful to be able to use find in project files, open a preview tab, copy the code I need, and not have the file stay open and clutter my tabs.
I also think it's nice to have consistency with the tree view, so single click = preview tab, double click = permanent tab. Once you get used to it, it should be good.
benogle commentedon Jan 6, 2016
Basically it makes the most intuitive sense to me. My thinking is similar to @adambuczynski. I dont necessarily want to commit to opening the file I click on, just have a better look at the context, or copy some code.
I just checked sublime. Both 2 and 3 has a text interface that just selects the line when single clicking on an item or match (no open file for me) then opening the file as permanent on double click. I have a totally vanilla sublime install in both cases.
acontreras89 commentedon Jan 27, 2016
Can we know what the progress on this is? I see @kuychaco has been making these changes where needed. Are we missing something?
nathansobo commentedon Jan 27, 2016
@kuychaco's improvements are in 1.5.x, which is on the beta channel as I write this. We're still not bringing up the preview in many circumstances because work is still in progress ensuring a reasonable upper time bound on that operation. When it's fast, we'll preview in more circumstances. @benogle do you think this can be closed for now and perhaps replaced with an issue addressing any remaining work?
benogle commentedon Jan 27, 2016
Let's close it. The only bit that might come later is opening in preview mode when moving through the fuzzy finder, but we need to be faster at opening files before that can happen.
benogle commentedon Jan 27, 2016
Thanks @kuychaco 🎉
acontreras89 commentedon Jan 27, 2016
Great work! 👏
adamreisnz commentedon Jan 27, 2016
Thanks everyone, I will download the beta to check it out.
kuychaco commentedon Jan 28, 2016
Thanks 😄
adamreisnz commentedon Feb 10, 2016
@benogle I've downloaded 1.5.0, but noticed that files opened from fuzzy finder or external sources are still opened as temporary tabs. Was this fix not supposed to be in 1.5.0?
benogle commentedon Feb 10, 2016
It'll be out in 1.6, which is in beta now!
adamreisnz commentedon Feb 10, 2016
Bugger! Was so looking forward to it already :)
lock commentedon Apr 14, 2018
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!