Skip to content

respect configured editor - #814

Merged
vilmibm merged 3 commits into
masterfrom
respect-editor
Apr 22, 2020
Merged

vilmibm merged 3 commits into
masterfrom
respect-editor

Conversation

@vilmibm

@vilmibm vilmibm commented Apr 22, 2020 •

Copy link
Copy Markdown
Contributor

fixes #308

gh now respects and prioritizes whatever is set with gh config set editor .... it chooses an editor in this way:

  • set in GH_EDITOR?
  • explicitly configured via gh config?
  • set in GIT_EDITOR?
  • set in VISUAL?
  • set in EDITOR?
  • nano (!windows), notepad (windows)

unfortunately adding tests did not make sense as the relevant change is below the level at which we can reasonably test survey code. the surface area is small and i think the risk is low.

@vilmibm
vilmibm requested review from mislav and probablycorey April 22, 2020 16:37

@mislav mislav left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the simplicity of this change!

One note though: now it's not possible to use any environment variable to override editor for a single invocation of gh anymore. Could we consider supporting an additional environment variable to allow this, perhaps something like GH_EDITOR, and have that variable have precedence over gh config?

$ git config --global core.editor vim
$ git var GIT_EDITOR
vim
$ EDITOR=nano git var GIT_EDITOR
vim
$ GIT_EDITOR=nano git var GIT_EDITOR
nano

Comment thread pkg/surveyext/editor.go Outdated
EditorName string
}

func (e *GhEditor) editorName() string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the method is called "editor name", but it can contain the full invocation path for the editor plus extra arguments I think. Because of that, I think the "name" part might be a slight misnomer because there is more that it can contain than just a name

Perhaps editorCommand would be a better name?

Comment thread pkg/surveyext/editor.go Outdated
// EXTENDED to enable different prompting behavior
type GhEditor struct {
*survey.Editor
EditorName string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto: this is called EditorName but can contain the full invocation line which is latter shellsplit. In name it's similar to EditorTemplateData.EditorName, but not in behavior. Therefore I would suggest a different name to help clarify the difference

@vilmibm
vilmibm merged commit f7aea8e into master Apr 22, 2020
@mislav
mislav deleted the respect-editor branch June 25, 2020 14:37
kachick added a commit to kachick/dotfiles that referenced this pull request Jun 9, 2024
Especially vscode is heavy in `gh pr create` use
cli/cli#814
kachick added a commit to kachick/dotfiles that referenced this pull request Jun 9, 2024
Especially vscode is heavy in `gh pr create` use
cli/cli#814
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to configure a default editor for use with gh

2 participants