Skip to content
Browse files

When the command is invoked on a line which is not a call to ADD_SUBD…

…IRECTORY, show a menu of all available subdirectories to move to.

Changed key equivalent to ⌥⌘↓ to reflect the new semantics.

git-svn-id: http://svn.textmate.org/trunk/Review/Bundles/CMake.tmbundle@11039 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
1 parent 62e62a5 commit a1a260c5cb8edf1fe2fb62be3ebd0702f904f1dd @ciaran ciaran committed Dec 19, 2008
Showing with 21 additions and 8 deletions.
  1. +21 −8 Commands/Open Included Listfile.tmCommand
View
29 Commands/Open Included Listfile.tmCommand
@@ -7,26 +7,39 @@
<key>command</key>
<string>#!/usr/bin/env ruby
require ENV['TM_SUPPORT_PATH'] + '/lib/textmate'
+require ENV['TM_SUPPORT_PATH'] + '/lib/ui'
abort "Unsaved file" unless ENV['TM_FILEPATH']
-line = STDIN.read
+line = STDIN.read
+dir = File.dirname(ENV['TM_FILEPATH'])
+subdir = nil
if line =~ /ADD_SUBDIRECTORY\s*\((.+?)\)/i
- path = File.join(File.dirname(ENV['TM_FILEPATH']), $1 + "/CMakeLists.txt")
- abort "The file at #{$1 + "/CMakeLists.txt"} doesn't exist" unless File.exist?(path)
- TextMate.go_to(:file =&gt; path)
+ subdir = $1
else
- abort "No ADD_SUBDIRECTORY command found"
-end</string>
+ subdirs = Dir[dir + "/*/CMakeLists.txt"].map { |p| File.basename(File.dirname(p)) }.sort
+ abort "No listfile found in subdirectories" if subdirs.empty?
+ choice = TextMate::UI.menu(subdirs)
+ abort "Cancelled" unless choice
+ subdir = subdirs[choice]
+end
+
+if subdir
+ file = subdir + "/CMakeLists.txt"
+ path = File.join(dir, file)
+ abort "The file at #{file} doesn't exist" unless File.exist?(path)
+ TextMate.go_to(:file =&gt; path)
+end
+</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
- <string>@D</string>
+ <string>~@</string>
<key>name</key>
- <string>Open Included Listfile</string>
+ <string>Move to Subdirectory Listfile</string>
<key>output</key>
<string>showAsTooltip</string>
<key>scope</key>

0 comments on commit a1a260c

Please sign in to comment.
Something went wrong with that request. Please try again.