Skip to content

Commit 04c8e89

Browse files
committed
edit: enable Sublime Text project view
1 parent bdc3391 commit 04c8e89

File tree

3 files changed

+48
-10
lines changed

3 files changed

+48
-10
lines changed

Diff for: .gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,7 @@
194194
# Unignore tests' bundle config
195195
!/Library/Homebrew/test/.bundle/config
196196

197-
# Unignore vscode configuration
197+
# Unignore editor configuration
198+
!/.sublime
199+
/.sublime/homebrew.sublime-workspace
198200
!/.vscode

Diff for: .sublime/homebrew.sublime-project

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"folders":
3+
[
4+
{
5+
"//": "Generated based on the contents of our .gitignore",
6+
"path": "..",
7+
"folder_exclude_patterns": [
8+
"Caskroom",
9+
"Cellar",
10+
"Frameworks",
11+
"bin",
12+
"etc",
13+
"include",
14+
"lib",
15+
"opt",
16+
"sbin",
17+
"share",
18+
"var",
19+
"Library/Homebrew/LinkedKegs",
20+
"Library/Homebrew/Aliases"
21+
],
22+
"follow_symlinks": true
23+
}
24+
],
25+
"settings": {
26+
"tab_size": 2
27+
}
28+
}

Diff for: Library/Homebrew/dev-cmd/edit.rb

+17-9
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,24 @@ def edit
4040
EOS
4141
end
4242

43-
paths = args.named.to_paths.select do |path|
44-
next path if path.exist?
43+
paths = if args.named.empty?
44+
# Sublime requires opting into the project editing path,
45+
# as opposed to VS Code which will infer from the .vscode path
46+
if which_editor == "subl"
47+
["--project", "#{HOMEBREW_REPOSITORY}/.sublime/homebrew.sublime-project"]
48+
else
49+
# If no formulae are listed, open the project root in an editor.
50+
[HOMEBREW_REPOSITORY]
51+
end
52+
else
53+
args.named.to_paths.select do |path|
54+
next path if path.exist?
4555

46-
raise UsageError, "#{path} doesn't exist on disk. " \
47-
"Run #{Formatter.identifier("brew create --set-name #{path.basename} $URL")} " \
48-
"to create a new formula!"
49-
end.presence
50-
51-
# If no formulae are listed, open the project root in an editor.
52-
paths ||= [HOMEBREW_REPOSITORY]
56+
raise UsageError, "#{path} doesn't exist on disk. " \
57+
"Run #{Formatter.identifier("brew create --set-name #{path.basename} $URL")} " \
58+
"to create a new formula!"
59+
end.presence
60+
end
5361

5462
exec_editor(*paths)
5563
end

0 commit comments

Comments
 (0)