<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,10 @@
 JavaScript Tools TextMate Bundle
 --------------------------------
+v0.2.7 (Sat Jul  5 17:32:41 EDT 2008) -- Thomas Aylott
++ Made the Lint Validator work with a selection and fallback to the whole document
++ Converted the Lint code into a method so that it could theoretically be required by another file
++ Added some basic Unit Tests for lint.rb
+
 v0.2.6 (Sat May 17 20:14:50 EDT 2008) -- Thomas Aylott
 + Now you can just set and environment variable to toggle the Packr base62 option
 </diff>
      <filename>CHANGELOG.txt</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
-&lt;!DOCTYPE plist PUBLIC &quot;-//Apple Computer//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
+&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
 &lt;plist version=&quot;1.0&quot;&gt;
 &lt;dict&gt;
 	&lt;key&gt;beforeRunningCommand&lt;/key&gt;
@@ -8,9 +8,10 @@
 	&lt;string&gt;. &quot;$TM_SUPPORT_PATH/lib/webpreview.sh&quot;
 html_header &quot;Validate Javascript&quot;
 &quot;${TM_RUBY:-ruby}&quot; &quot;$TM_BUNDLE_SUPPORT/bin/lint.rb&quot;
-html_footer&lt;/string&gt;
+html_footer
+&lt;/string&gt;
 	&lt;key&gt;input&lt;/key&gt;
-	&lt;string&gt;none&lt;/string&gt;
+	&lt;string&gt;selection&lt;/string&gt;
 	&lt;key&gt;keyEquivalent&lt;/key&gt;
 	&lt;string&gt;^V&lt;/string&gt;
 	&lt;key&gt;name&lt;/key&gt;
@@ -18,7 +19,7 @@ html_footer&lt;/string&gt;
 	&lt;key&gt;output&lt;/key&gt;
 	&lt;string&gt;showAsHTML&lt;/string&gt;
 	&lt;key&gt;scope&lt;/key&gt;
-	&lt;string&gt;source.js, source.prototype.js&lt;/string&gt;
+	&lt;string&gt;source.js&lt;/string&gt;
 	&lt;key&gt;uuid&lt;/key&gt;
 	&lt;string&gt;4108455E-925C-4009-B87F-4635199F6DE7&lt;/string&gt;
 &lt;/dict&gt;</diff>
      <filename>Commands/Run JavaScript Lint on current file.tmCommand</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,20 @@
 #!/usr/bin/env ruby
 FILENAME = ENV['TM_FILENAME']
 FILEPATH = ENV['TM_FILEPATH']
-SUPPORT  = ENV['TM_BUNDLE_SUPPORT']
+# SUPPORT  = ENV['TM_BUNDLE_SUPPORT']
+SUPPORT  = '/Users/taylott/Library/Application Support/TextMate/Bundles/JavaScript Tools.tmbundle/Support'
 BINARY   = &quot;#{SUPPORT}/bin/jsl&quot;
 # BINARY   = `uname -a` =~ /i386/ ? &quot;#{SUPPORT}/bin/intel/jsl&quot; : &quot;#{SUPPORT}/bin/ppc/jsl&quot;
 
-output = `&quot;#{BINARY}&quot; -process &quot;#{FILEPATH}&quot; -nologo -conf &quot;#{SUPPORT}/conf/jsl.textmate.conf&quot;`
+def lint!(javascript,offset_line=0,offset_column=0)
+# File.write
+# output = `&quot;#{BINARY}&quot; -process &quot;#{FILEPATH}&quot; -nologo -conf &quot;#{SUPPORT}/conf/jsl.textmate.conf&quot;`
+output = IO::popen(%`&quot;#{BINARY}&quot; -stdin -nologo -conf &quot;#{SUPPORT}/conf/jsl.textmate.conf&quot; 2&gt;&amp;1`, 'r+') do |io|
+  io &lt;&lt; javascript
+  io.close_write
+  io.read.chomp
+end
+
 
 output.gsub!('lint warning:', '&lt;span class=&quot;warning&quot;&gt;Warning:&lt;/span&gt;')
 output.gsub!('SyntaxError:', '&lt;span class=&quot;error&quot;&gt;Syntax Error:&lt;/span&gt;')
@@ -26,10 +35,14 @@ output  = output.map do |chunk|
   j = 0
   lines = lines.map do |line|
     if line =~ /^(\d+):/
-      column = (lines[j+2].rindex(&quot;^&quot;) + 1).to_s rescue ''
-      line.gsub!(/^(\d+):/, %{&lt;a href=&quot;txmt://open?url=file://#{FILEPATH}&amp;line=\\1&amp;column=#{column}&quot;&gt;\\1&lt;/a&gt;})
-      line.gsub!('#{column}', column);
-      line.gsub!('#{FILEPATH}', FILEPATH);
+      
+      linenum = line.scan(/^(\d+):/).first.first
+      linenum = linenum.to_i + offset_line rescue 1
+      
+      column = lines[j+2].rindex(&quot;^&quot;) rescue 1
+      column = column.to_i + 1 + offset_column rescue 1
+      
+      line.gsub!(/^(\d+):/, %{&lt;a href=&quot;txmt://open?url=file://#{FILEPATH}&amp;line=#{linenum}&amp;column=#{column}&quot;&gt;\\1&lt;/a&gt;})
     end
     j += 1
     line
@@ -43,7 +56,7 @@ output  = output.map do |chunk|
 end
 output = output.join(&quot;\n\n&quot;)
 
-html = &lt;&lt;WTF
+html = &lt;&lt;-HTML
 &lt;html&gt;
   &lt;head&gt;
     &lt;title&gt;JavaScript Lint Results&lt;/title&gt;
@@ -94,6 +107,42 @@ html = &lt;&lt;WTF
     &lt;/ul&gt;
   &lt;/body&gt;
 &lt;/html&gt;  
-WTF
+HTML
+
+html
+end
+
+if __FILE__ == $0
+
+if ENV['TM_SCOPE'] =~ /source\.js/
+  puts lint!(STDIN.read, ENV['TM_INPUT_START_LINE'].to_i, ENV['TM_INPUT_START_COLUMN'].to_i)
+else
+  require &quot;test/unit&quot;
+  class TestLint &lt; Test::Unit::TestCase
+    def test_basic
+      js = '1+1;'
+      result = lint!(js)
+      assert result.include?('0 error(s), 0 warning(s)'), result
+    end
+    def test_basic_error
+      js = '&quot;'
+      result = lint!(js)
+      assert result.include?('1 error(s), 0 warning(s)'), result
+      assert result.include?('&amp;line=1&amp;column=1'), result
+    end
+    def test_offset
+      js = '&quot;'
+      result = lint!(js, 100)
+      assert result.include?('1 error(s), 0 warning(s)'), result
+      assert result.include?('&amp;line=101&amp;column=1'), result
+    end
+    def test_offset2
+      js = &quot;{'singleQuotedString': null}&quot;
+      result = lint!(js, 100, 100)
+      assert result.include?('1 error(s), 0 warning(s)'), result
+      assert result.include?('&amp;line=101&amp;column=122'), result
+    end
+  end
+end #TESTING
 
-puts html
\ No newline at end of file
+end #if</diff>
      <filename>Support/bin/lint.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>cc2f43b7118740d95d5a9f10ee9a9909282de418</id>
    </parent>
  </parents>
  <author>
    <name>Thomas Aylott</name>
    <email>oblivious+git@subtlegradient.com</email>
  </author>
  <url>http://github.com/johnmuhl/javascript-tools-tmbundle/commit/7aefb596a603171a38b0a92b96b0db832944de03</url>
  <id>7aefb596a603171a38b0a92b96b0db832944de03</id>
  <committed-date>2008-07-05T14:40:21-07:00</committed-date>
  <authored-date>2008-07-05T14:40:21-07:00</authored-date>
  <message>+ Made the Lint Validator work with a selection and fallback to the whole document
+ Converted the Lint code into a method so that it could theoretically be required by another file
+ Added some basic Unit Tests for lint.rb</message>
  <tree>1aff3000fcc0d57670e763a6c2aa0ed453c56239</tree>
  <committer>
    <name>Thomas Aylott</name>
    <email>oblivious+git@subtlegradient.com</email>
  </committer>
</commit>
