Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Settings view throws an exception if opened in a different pane from where it is already open #723

Closed

Description

@WalterGR

Steps to Reproduce:

  1. Open Atom in safe mode
  2. Ensure the settings-view is not open
  3. Split right so you have two panes open
  4. In the left pane open the settings-view using Ctrl-,
  5. In the right pane open the settings-view using Ctrl-,
  6. Expected: settings-view to focus on the already opened settings-view in the left pane, Actual: Exception in console
    image

From this state you can get weird errors like: atom/atom#12498

Refs (Same bug in atom/about): atom/about#30


Expected:

"n update(s)" and the icon disappear. One of the Settings tabs is switched to and the "Updates" section displayed.

Actual:

"n update(s)" and the icon disappear. Nothing else (at least visibly) happens.

Atom 1.4.0 in OS X 10.10.5.

Screen recording showing the bug:

atom-clicking-update-available-in-status-bar-does-nothing-if-settings-are-open-in-multiple-tabs

Activity

  1. WalterGR commented on Jan 19, 2016

    @WalterGR
    Author

    Here's another instance of incorrect behavior, which I think is probably due to the same bug.

    Repro:

    1. Have Settings open in a pane.
    2. Make any tab other than that Settings tab be the active tab in that pane. (Or stated differently: ensure that the Settings tab isn't active.)
    3. Move focus to a different pane.
    4. Click the "n update(s)" text.

    Expected:

    "n update(s)" and the icon disappear. One of the Settings tabs is switched to and the "Updates" section displayed.

    Actual:

    "n update(s)" and the icon disappear. Nothing else visibly happens. But Atom has opened Settings: in the active pane, behind the current tab.

    Screen recording showing this behavior:

    atom-clicking-n-updates-can-open-settings-behind-an-existing-tab

    Unfortunately the GIF is pretty fast. This is what it shows:

    • Cursor wiggle under Settings tab that isn't active.
    • Click a different pane to move focus there.
    • Click "2 updates".
    • Nothing appears to happen.
    • Turn on Key Binding Resolver.
    • Show that Settings has opened 'behind' the "Clojure REPL" tab by using pane:show-next-item and pane:show-previous-item.
  2. changed the title [-]Clicking "n update(s)" text in status bar has no effect if Settings is open in multiple tabs[/-] [+]Clicking "n update(s)" text in status bar has no effect if Settings is open in multiple tabs, or in a pane that doesn't have focus[/+] on Jan 23, 2016
  3. WalterGR commented on Jan 23, 2016

    @WalterGR
    Author

    (Updating title to account for my "Here's another instance of incorrect behavior" comment above.)

  4. changed the title [-]Clicking "n update(s)" text in status bar has no effect if Settings is open in multiple tabs, or in a pane that doesn't have focus[/-] [+]Clicking "n update(s)" text in status bar has no effect if Settings is already open in certain situations[/+] on Jan 23, 2016
  5. Ben3eeE commented on Aug 9, 2016

    @Ben3eeE
    Contributor

    I'm pretty sure this issue describes the same thing as atom/atom#11199, just that this has a different way of opening the settings view.

  6. changed the title [-]Clicking "n update(s)" text in status bar has no effect if Settings is already open in certain situations[/-] [+]Settings view throws an exception if opened in a different pane from where it is already open[/+] on Dec 29, 2016
  7. winstliu commented on Jan 3, 2018

    @winstliu
    Contributor

    Here's the current behavior. Exception still shows up in console. Pretty odd.
    multiple-settings-views

  8. t9md commented on Jan 24, 2018

    @t9md
    Contributor

    I was investigating this.
    Now I'm clear why this happens.

    Trying to send PR after think a bit more.

    To make explanation clear, I will

    • Refer setting-view as SV
    • Use open's URI(atom://config) directly instead of saying "invoke settings-view:open
      • settings-view:open invoke atom.workspace.open("atom://config")
      • settings-view:core invoke atom.workspace.open("atom://config/core")
      • settings-view:change-themes invoke atom.workspace.open("atom://config/themes")

    Preparation

    open two panes(p1 and p2), then activate p1, open atom//config

                p1(active)                 p2
    +-------------------------+-------------------------+
    | atom://config           |                         |
    |                         |                         |
    |                         |                         |
    |                         |                         |
    |                         |                         |
    +-------------------------+-------------------------+
    
    • When p1 is active

      • OK: atom://config
      • OK: atom://config/core
      • OK: atom://config/themes
    • When p2 is active

      • NG: atom://config by trying to open cached settingsView item on pane p2
      • OK: atom://config/core: p1 activated
      • OK: atom://config/themes: p1 activated

    Why?

    Short explanation

    • When trying to open specific panel, it make already opened setting-view's pane active in opener.
    • So calling pane.activateItem(item) have no issue.
    • But when trying to open without panel(just atom://config), it have no panel path. SV's pane is not activated in opener.
    • So calling pane.activateItem(item) is called against different pane of already opened SV's pane which result
    • Which is trying to open exact item in different pane The workspace can only contain one instance of item

    How it happens

    Later two URI's(/core, /themes) have panel's path and it invokes settingsView.showPanel(panelName, options)

    settingsView.showPanel(panelName, options)

    Which eventually call panel.focus, which make already opened setting-view item's pane active.

    panel.focus()

    Then this line's container.getActivePane() return's same pane of already opened setting-view item.
    https://github.com/atom/atom/blob/8ba04f0f0c184ab1522be5129ad511752d2c3e9c/src/workspace.js#L1001

    Quick solution

    • Activate setting's view item in opener regardless of URI have panel path.
    • Which eventually simulate searchAllPanes: true option in workspace.open.
    • No longer trying to open SV's item in different pane.
    • Why we can't use this option here is SV item's getURI() is not usable as identity of item(URI is set to URI which initially created).
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