Skip to content

Commit

Permalink
Fmt updates document without saving the current version
Browse files Browse the repository at this point in the history
When running Fmt command, the file is not being saved before formatting,
just the window content is being replaced. Errors show in a tooltip.

Cherrypick 8d91c92 from tg
tg authored and syscrusher committed Sep 19, 2015
1 parent cf4a250 commit 998d17a
Showing 2 changed files with 4 additions and 25 deletions.
9 changes: 4 additions & 5 deletions Commands/Fmt.tmCommand
Original file line number Diff line number Diff line change
@@ -3,13 +3,12 @@
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>saveModifiedFiles</string>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env ruby18
<string>#!/usr/bin/env bash
. "${TM_SUPPORT_PATH}/lib/bash_init.sh"
require "#{ENV['TM_BUNDLE_SUPPORT']}/gomate"
Go::gofmt
</string>
(eval "${TM_GOFMT:-gofmt}") || exit_show_tool_tip</string>
<key>input</key>
<string>document</string>
<key>inputFormat</key>
20 changes: 0 additions & 20 deletions Support/gomate.rb
Original file line number Diff line number Diff line change
@@ -70,24 +70,4 @@ def Go::godoc
TextMate.exit_show_tool_tip(err)
end
end

def Go::gofmt
# TextMate's special TM_GOFMT or expect 'gofmt' on PATH
gofmt_cmd = ENV['TM_GOFMT'] || 'gofmt'
TextMate.save_if_untitled('go')

args = []
args.push(gofmt_cmd)
args.push(ENV['TM_FILEPATH'])

out, err = TextMate::Process.run(*args)

if err.nil? || err == ''
puts out
else
args << {:use_hashbang => false, :version_args => ['version'], :version_regex => /\Ago version (.*)/}
TextMate::Executor.run(*args)
TextMate.exit_show_html
end
end
end

0 comments on commit 998d17a

Please sign in to comment.