Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Fix preview tabs #9165

Closed
Closed

Description

@benogle

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:

  1. 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
  2. Close the preview tab when it loses focus

The issues

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

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

  1. benogle commented on Oct 15, 2015

    @benogle
    ContributorAuthor

    Moved to core cause the API is a core concern, and this discussion touches packages other than tabs.

  2. nathansobo commented on Oct 15, 2015

    @nathansobo
    Contributor

    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 notifies onDidAddItem listeners with a new preview property 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 if previewItem is called again with another item. The preview item "graduates" to a normal item if addItem is called with the same item or the item implements onDidChangeModified and its status changes to true.

    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.

    • onDidStopPreviewingItem Did we stop previewing because the item got removed or because the item is done being previewed.
    • onDidMakeItemPermanent I 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.
    • onDidConfirmPreviewItem Vague verb.
    • onDidRatifyPreviewItem Sounds like a trade agreement.
    • onDidGraduatePreviewItem
    • onDidAdoptPreviewItem

    Someone 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?

  3. billybonks commented on Oct 25, 2015

    @billybonks

    onDidSelectPreviewItem preview item upgraded
    onDidOpenPreviewItem or onDidChangePrewviewItem changed preview item

  4. nathansobo commented on Oct 25, 2015

    @nathansobo
    Contributor

    Now I'm liking onDidRetainPreviewedItem to describe the moment where a preview item is converted into a regular item.

  5. billybonks commented on Oct 25, 2015

    @billybonks

    I like the verb but prefer the present tense onDidRetainPreviewItem you cant retain it if you didn't preview it.

    one issue i have with your rough api description is:

    The preview item is removed if the pane receives and then loses focus. The preview item is replaced if previewItem is called again with another item

    in order to do this, the preview pane needs be given focus when it is opened. this wouldn't work well for this feature:
    Navigating the treeview with ↕️, opens a preview pane whenever a item is selected.

    • Keypress up
    • open preview pane
    • Keypress up
    • replaces preview pane
      etc

    with the former mentioned api behaviour, the workflow would be:

    • Keypress up
    • opens preview pane, focuses it.
    • hotkey focus treeview
    • preview pane closes
    • (repeat flow)
  6. adamreisnz commented on Nov 10, 2015

    @adamreisnz

    Glad to see this being progressed. Has there been a definite decision on whether the "short term approach" is going to be implemented?

  7. nathansobo commented on Nov 10, 2015

    @nathansobo
    Contributor

    Adding these core APIs and using them in select bundled packages is pretty near term on the roadmap.

  8. adamreisnz commented on Nov 10, 2015

    @adamreisnz

    Great, thanks

  9. paulpflug commented on Dec 17, 2015

    @paulpflug

    Why is it added to the pane? Is there a use case other than previewing in a texteditor?
    This is what I would need:

    atom.workspace.observeTextEditors (editor) =>
      if editor.isPreview
        editor.onClearPreview -> #something
        editor.clearPreview()
  10. kuychaco commented on Jan 6, 2016

    @kuychaco
    Contributor

    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

    @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

  11. adamreisnz commented on Jan 6, 2016

    @adamreisnz

    @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.

  12. benogle commented on Jan 6, 2016

    @benogle
    ContributorAuthor

    @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

    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.

  13. acontreras89 commented on Jan 27, 2016

    @acontreras89
    Contributor

    Can we know what the progress on this is? I see @kuychaco has been making these changes where needed. Are we missing something?

  14. nathansobo commented on Jan 27, 2016

    @nathansobo
    Contributor

    @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?

  15. benogle commented on Jan 27, 2016

    @benogle
    ContributorAuthor

    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.

  16. benogle commented on Jan 27, 2016

    @benogle
    ContributorAuthor

    Thanks @kuychaco 🎉

  17. acontreras89 commented on Jan 27, 2016

    @acontreras89
    Contributor

    Great work! 👏

  18. adamreisnz commented on Jan 27, 2016

    @adamreisnz

    Thanks everyone, I will download the beta to check it out.

  19. kuychaco commented on Jan 28, 2016

    @kuychaco
    Contributor

    Thanks 😄

  20. adamreisnz commented on Feb 10, 2016

    @adamreisnz

    @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?

  21. benogle commented on Feb 10, 2016

    @benogle
    ContributorAuthor

    It'll be out in 1.6, which is in beta now!

  22. adamreisnz commented on Feb 10, 2016

    @adamreisnz

    Bugger! Was so looking forward to it already :)

  23. lock commented on Apr 14, 2018

    @lock

    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!

  24. locked and limited conversation to collaborators on Apr 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions