Skip to content

Github Desktop and Default text editors + EmEditor #4753

Closed

Description

@killerwife

Currently github desktop only supports selective text editors on windows. It does not respect two following key settings:

  1. using default text editor as setup in windows for given file type
  2. using default text editor set in git config

I have both of these set to EmEditor, the old Github desktop client is capable of using them properly, but the new one does not even give the option to change this. Using notepad is insanity when doing cross platform development, and installing an additional editor just because the client does not support setting it in some sane way is no good either.

Reason for using EmEditor: we use extremely huge files and as a result, most of not all software is incapable of handling it well. (talking about 1GB + files here)

I have not seen an EmEditor thread around here yet.

Activity

  1. agisilaos commented on May 22, 2018

    @agisilaos
    Member

    Hello @killerwife,

    Currently github desktop only supports selective text editors on windows. It does not respect two following key settings:

    1. using default text editor as setup in windows for given file type
    2. using default text editor set in git config

    I'm not sure how to help you or answer the first part of the issue, so maybe someone from the core team can answer your questions cc: @shiftkey, @iAmWillShepherd.

    Now regarding the integration of EmEditor with the new Github Desktop, there is a doc about it and how external contributors can integrate their favorite editor with the app. The team (myself included) would be more than happy to review your PR and help you with any questions that you may have. Please let me know if you have any other questions.

  2. steveward commented on May 22, 2018

    @steveward
    Contributor

    Thanks for opening this @killerwife.

    using default text editor as setup in windows for given file type

    GitHub Desktop should respect the default program you have set to open a specific file type when you select Open with default program in the context menu of a file in the Changes view. Is this what you are looking for?

  3. added
    more-info-needed
    on May 22, 2018
  4. killerwife commented on May 22, 2018

    @killerwife
    Author

    Absolutely. When I associate a given editor with .cpp or .h or .py, I would expect the Github Desktop app to use that associated program. Just to clarify on windows 10 its the menu called "Choose default apps by file type".

  5. steveward commented on May 22, 2018

    @steveward
    Contributor

    When I associate a given editor with .cpp or .h or .py, I would expect the Github Desktop app to use that associated program

    GitHub Desktop should respect that default program when you right-click on a file in the Changes view and select Open with default program. Let me know if I'm misunderstanding what you are wanting to do here.

  6. killerwife commented on May 22, 2018

    @killerwife
    Author

    Yes. When I used https://imgur.com/a/W2n3mAB "Open with default program", notepad was used. When I used "show in explorer" and doubleclicked the file, EmEditor was used.
    Edit: also when I use "Open File" on the old Github Desktop, the non portable one which was only for windows i believe, https://imgur.com/a/yz8PbL2 <- this one, the correct EmEditor is used. So on the old client this used to work fine.

  7. shiftkey commented on May 28, 2018

    @shiftkey
    Member

    There's some extra context here about the differences between the classic Windows app and the new Electron app, and it requires some understanding of how Windows handles opening files.

    Windows app all end up funnelling through ShellExecute to ask the OS how to handle a given file. Electron too has support for opening a file in the user's preferred program - shell.openItem(fullPath) and shell.openExternal(url).

    How openExternal works on Windows is important:

      if (reinterpret_cast<ULONG_PTR>(ShellExecuteW(NULL, L"open",
                                                    escaped_url.c_str(), NULL, NULL,
                                                    SW_SHOWNORMAL)) <= 32) {
        // We fail to execute the call. We could display a message to the user.
        // TODO(nsylvain): we should also add a dialog to warn on errors. See
        // bug 1136923.
        return false;
      }

    Notice that L"open",? This is where the first problem comes in: Windows expects a verb to ShellExecute to hint at what the user wants to do with the file, and Electron currently hard-codes open.

    So while EmEditor does declare itself as an editor for text files, Electron is only leveraging programs that support opening a given extension. That's the core of the differences between Classic Desktop and Desktop Electron, and why that menu item is currently labelled Open in default program and not Edit in default program.

    Putting that aside, I tested out installing EmEditor and Desktop and associating it with opening a file extension (in this case .md). On first usage I got this prompt, which makes sense:

    So I chose EmEditor and it opened fine. Second time through, I hit this error:

    This is our generic error handler when Electron raises an error inside open-file.ts:

    const error = {
    name: 'no-external-program',
    message: `Unable to open file ${fullPath} in an external program. Please check you have a program associated with this file extension`,
    }
    await dispatcher.postError(error)

    That probably needs to be investigated here.

    It does not respect two following key settings:

    ...
    2. using default text editor set in git config

    I believe this was working because we set core.editor to gitpad in your config - GitPad being a tool that we bundled in Git Shell. We don't have plans to bring Git Shell across to Desktop Electron.

  8. added
    investigation-needed
    and removed
    more-info-needed
    on May 28, 2018
  9. zekrom-vale commented on Jun 29, 2018

    @zekrom-vale

    It is annoying that "Open in external editor" is not hidden if there is no external editor, cluttering up the context menu. I would think this is easy to check and hide.

  10. shiftkey commented on Aug 15, 2018

    @shiftkey
    Member

    @killerwife in reference to this feature that is no longer set by Desktop Electron:

    using default text editor set in git config

    In Desktop Classic on Windows we set core.editor=gitpad which would launch the default program for editing text files. A while ago the Git for Windows project added the ability to choose the editor from a list of installed tools at install time:

    This is great for discoverability, but all it does under the hood is set core.editor to the program and provide the necessary arguments to launch the program and detect when it was closed.

    Here's what it adds to my test machine's system config for Notepad++:

    [core]
    	editor = 'C:\\Program Files\\Notepad++\\notepad++.exe' -multiInst -notabbar -nosession -noPlugin
    

    Desktop isn't really concerned about this flow in the UI (commits are done in the app, rather than launching the editor) so I'm not sure when we'll get to this.

    For the moment I'd see if you can add an entry like this to your ~/.gitconfig to address this gap from the old app:

    [core]
    	editor = 'C:\\Users\[account]\\AppData\\Local\\Programs\\EmEditor\\EmEditor.exe' 
    

    I'm not sure if there are any other arguments to add on the end, based on the options available.

  11. shiftkey commented on Aug 15, 2018

    @shiftkey
    Member
    1. using default text editor as setup in windows for given file type
    2. using default text editor set in git config

    After discussion in #5406 about 1. I've extracted the current details about Desktop's limitations to #5411, and I believe 2. should be covered by a config change, so I'm going to close this out because I don't think there's anything more I can do to support EmEditor currently.

  12. KirkH420 commented on Nov 1, 2021

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

    investigation-needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions