Skip to content

Commit

Permalink
Merge pull request #14601 from apainintheneck/stop-double-warning-in-…
Browse files Browse the repository at this point in the history
…edit

cmd/edit: stop double warning
  • Loading branch information
MikeMcQuaid authored Feb 12, 2023
2 parents e940f77 + a7dbd73 commit f4f22bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/edit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def edit
paths = if args.named.empty?
# Sublime requires opting into the project editing path,
# as opposed to VS Code which will infer from the .vscode path
if which_editor == "subl"
if which_editor(silent: true) == "subl"
["--project", "#{HOMEBREW_REPOSITORY}/.sublime/homebrew.sublime-project"]
else
# If no formulae are listed, open the project root in an editor.
Expand Down
14 changes: 8 additions & 6 deletions Library/Homebrew/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def which_all(cmd, path = ENV.fetch("PATH"))
end.compact.uniq
end

def which_editor
def which_editor(silent: false)
editor = Homebrew::EnvConfig.editor
return editor if editor

Expand All @@ -371,11 +371,13 @@ def which_editor
end
editor ||= "vim"

opoo <<~EOS
Using #{editor} because no editor was set in the environment.
This may change in the future, so we recommend setting EDITOR,
or HOMEBREW_EDITOR to your preferred text editor.
EOS
unless silent
opoo <<~EOS
Using #{editor} because no editor was set in the environment.
This may change in the future, so we recommend setting EDITOR,
or HOMEBREW_EDITOR to your preferred text editor.
EOS
end

editor
end
Expand Down

0 comments on commit f4f22bc

Please sign in to comment.