Skip to content
Browse files

Fixing the last-line-invocation-hangs bug found by Allan. TM sends us…

… the line index, but reading from STDIN, we don't get the last line when it is blank. Thus we were indexing a nil. I also modified the script so it will fail, instead of hang, in the event of future issues.

git-svn-id: dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
1 parent 17f00a1 commit bd77dd4b570e9155b8dd5083f3392a77715a0112 @JEG2 JEG2 committed Nov 10, 2006
Showing with 10 additions and 1 deletion.
  1. +10 −1 Commands/Insert Missing Requires.plist
11 Commands/Insert Missing Requires.plist
@@ -11,13 +11,22 @@ $: << "#{ENV['TM_SUPPORT_PATH']}/lib"
require "escape"
require "open3"
+# make exceptions in the writing Thread kill the process so we don't hang
+Thread.abort_on_exception = true
CURSOR = [0xFFFC].pack("U").freeze
line, col = ENV["TM_LINE_NUMBER"].to_i - 1, ENV["TM_LINE_INDEX"].to_i
stdin, stdout, stderr = Open3.popen3("/usr/bin/env", "ruby", "#{ENV['TM_BUNDLE_SUPPORT']}/bin/insert_requires.rb") do
code =
- code[line][col...col] = CURSOR unless ENV.has_key?('TM_SELECTED_TEXT')
+ unless ENV.has_key?('TM_SELECTED_TEXT')
+ if code[line].nil? # if cursor was on the last line and it was blank
+ code << CURSOR
+ else
+ code[line][col...col] = CURSOR
+ end
+ end
stdin.write code.join

0 comments on commit bd77dd4

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