Skip to content

Handle uninstalled external editors #7463

Closed

Description

@dbrowndan

Description

This came up because I wanted to switch from Sublime to Atom. I started with Sublime as my "External editor". Then I had both editors installed for a time, then I uninstalled Sublime.

At this point, when I loaded up GitHub Desktop, Sublime was still set as my default external editor. But of course, then I couldn't successfully open anything in my default external editor, so I needed to change the setting. When I went to Options >> Advanced, Atom was the only option for "External editor", as expected.

image

The problem is that this setting doesn't save now. If I click the Save button, then check my default external editor, it still says Sublime Text. (A quick, easy way to check the "real" external editor is to click the "Repository" menu and see what it says for the Ctrl-Shift-A shortcut. I wanted it to say "Open in Atom" but it was still saying "Open in Sublime Text".)

image

My first guess is that this happens because GD doesn't detect any changes to the <select> dropdown. Atom is the only <option>, so nothing changes and hence, there's nothing to save. I was able to confirm this (somewhat) by adding a fake second <option> to the DOM that would save. Then I had to repeat that process to successfully workaround and switch from the fake editor to Atom.

At first, I thought this save issue was the main problem we needed to solve, but then I figured it's probably better to handle the uninstalled editor in the first place.

I think the ideal solution might be to automatically change the default editor on startup if the old one has been uninstalled. A challenge might be deciding what editor to pick if there are multiple editors still installed. But even then, we could just pick at random (or more realistically, choose the first installed editor on the list) because any installed editor is probably better than an uninstalled editor.

Note: This is related to #6114 but not the same. The proposed solution there (adding a button to scan for new or uninstalled editors) would probably not fix this. Even if we could re-scan for editors without restarting GD, the setting likely still would not save if there was only one option. (I think that's likely because I am able to scan for new editors by restarting GD and it doesn't solve this. So a manual scan button would probably not help me unless it was implemented with this issue in mind.)

Version

  • GitHub Desktop: 1.6.5
  • Operating system: Microsoft Windows [Version 10.0.17134.706]

Steps to Reproduce

  1. Install two valid default external editors
  2. Set one of them as your "External editor"
  3. Uninstall that same editor
  4. Restart GD and notice that the default editor is no longer valid
  5. Try to change the setting to the editor that is still installed and notice that it doesn't save

Expected Behavior

Either:

  1. The default editor should automatically change if it's uninstalled
    ...or...
  2. The "External editor" setting should save even if the actual dropdown doesn't appear to change

Actual Behavior

The default external editor stays set as the old, uninstalled editor and cannot be changed.

Additional Information

Logs

On startup, I get this error after uninstalling Sublime:
Uncaught (in promise) a: The editor 'Sublime Text' could not be found. Please open Options and choose an available editor. at Object.t.findEditorOrDefault (file:///C:/Users/Dan%20Brown/AppData/Local/GitHubDesktop/app-1.6.5/resources/app/renderer.js:14:101062)

There are no errors when trying to save the new setting (Atom) that doesn't actually save.

Activity

  1. tierninho commented on May 3, 2019

    @tierninho
    Contributor

    @dbrowndan First off, thank you for the excellent write-up, this is very helpful and a great start for us in pinpointing the cause of this issue! ✨

    We will try to reproduce the issue and circle back with the results. In the meantime –– if you'd like to help diagnose –– were you able to tell why it's not saving? No worries if you haven't got the time 😄as we are investigating 🔬

  2. dbrowndan commented on May 3, 2019

    @dbrowndan
    Author

    Thanks @tierninho! I'm quite new to open source so I'm trying to be as clear as I can. I've also never worked with React before so I'm flying a little blind here, but I had some new observations...

    I just confirmed that the "External editor" setting (even with just one, unchanged <option>) does save if I change the "Shell" setting to anything new. That means that the decision to save or not is probably based on whether anything in the <form> (or <dialogue>?) changes. That is, if anything changes, it saves everything.

    Part of me wonders if it's a React-level decision, then? Maybe React never fires onSubmit if nothing in the dialogue/form changes? See

    onSubmit={this.onSave}

  3. added
    help wanted
    investigation-needed
    on May 3, 2019
  4. tierninho commented on May 3, 2019

    @tierninho
    Contributor

    Great, appreciate the extra dive into diagnosing this. We all appreciate it 🥇

    When I tested this on both Mac (OSX 10.14.4) and Windows (10 v1803), the issue resolved itself on Step 5 of your reproduction steps. As you stated, Desktop failed to recognize that Atom was the new default editor upon restart, however as soon as I clicked Save in the settings, Atom was immediately active in the all menus and working as expected.

    But... one issue I did observe (in Windows at least) was that when I reopened Desktop and went to the settings to "save" Atom, that Atom was sometimes not visually present and the Install Atom? link was there instead. Of course Atom was already installed at this point.

    The point is that perhaps the internal process to detect the "new" editor was still running in the background so this delay temporarily caused the editor not to be recognized or function correctly. Just a guess for now, as this needs further investigation. On any future attempts, I suspect this will lead to your exact experience.

    Regardless of the above, this experience is sub-par and needs some tweaking to make it a better user experience. Although we cannot get to this right away, our engineers will be looking into this. The issue was also marked as help-wanted in case you want to sharpen your React chops and contribute to an open source project. No obligation of course, but we are forever grateful ⚡️

    If you spot any other observations with this or in Desktop, we'd love to know. Thanks again!

  5. added
    integrations
    on May 24, 2019
  6. kuychaco commented on Oct 17, 2019

    @kuychaco
    Contributor

    This was addressed in #8388 so I'm closing this out! ✌️

    Thanks for the report @dbrowndan! Your thoughtful write-up was a pleasure to read :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedintegrationsinvestigation-needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions