Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Merge requests
  • !8224

Fix guessEditor on linux for code-insiders

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/loiclefloch/fix/launchEditor into master Dec 23, 2019
  • Overview 4
  • Commits 2
  • Pipelines 0
  • Changes 1

Created by: loiclefloch

Hello,

While using create-react-app on linux, I found that I couldn't open a file if using code-insiders.

The problem was that we run the ps x --no-heading -o comm --sort=comm command to retrieve the user's processes. We put the command result in an output variable, which is a string. We then use indexOf on it to look for a common linux editor.

const COMMON_EDITORS_LINUX = {
  atom: 'atom',
  Brackets: 'brackets',
  code: 'code',
  'code-insiders': 'code-insiders',
  vscodium: 'vscodium',
  emacs: 'emacs',
  gvim: 'gvim',
  'idea.sh': 'idea',
  'phpstorm.sh': 'phpstorm',
  'pycharm.sh': 'pycharm',
  'rubymine.sh': 'rubymine',
  sublime_text: 'sublime_text',
  vim: 'vim',
  'webstorm.sh': 'webstorm',
  'goland.sh': 'goland',
};

Considering this list of editors, the indexOf method will found code on the output string and thus return code, while we are expecting to find code-insiders.

Making code-insiders above code on the list would work, but i preferred a much future-proof method.

Instead of making the indexOf on the output string, I split the output to a runningProcesses array. This way the indexOf is made on an array, not on the whole output string. It fixes the "priority problem" and allow to open files on code-insiders.

It also seem to be the method used if the platform is win32, so I tried to make the code consistent with it.

edit1: I have added nvim on the COMMON_EDITORS_LINUX map since with this fix it will not be taking into account anymore. Maybe there are other software that I am not aware of that could have the same problem.

This being my first PR ever, thank you to indicate me any thing I could have forgot.

Thank you,

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/loiclefloch/fix/launchEditor