Skip to content

Commit

Permalink
improved modified
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarolm committed Nov 22, 2019
1 parent 17c3738 commit cac9f73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Default.sublime-settings
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"goguru_version" : "0.1.19", // DO NOT MODIFY
"goguru_version" : "0.1.20", // DO NOT MODIFY
// Please do not edit this file, instead us the user config.

// use golangconfig, if false then shellenv will be used to get golang environment variables
Expand Down
15 changes: 7 additions & 8 deletions goGuru.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,26 +380,25 @@ def guru(self, end_offset, begin_offset=None, mode="describe", callback=None):
guru_json = "-json"

# Build guru cmd.
# quick messy -modified update 22/10/2019 (DD/MM/YYYY)
# modified update 22/10/2019 - 1 (DD/MM/YYYY)
contents = self.view.substr(sublime.Region(0, self.view.size()))
contents_size = self.view.size()
cmd = "%(toolpath)s -modified %(scope)s %(tags)s %(guru_json)s %(mode)s %(file_path)s:%(pos)s <<CSTDIN000\n%(file_path)s\n%(contents_size)s\n%(contents)sCSTDIN000" % {
contents_size = str(self.view.size())
cmd = "%(toolpath)s -modified %(scope)s %(tags)s %(guru_json)s %(mode)s %(file_path)s:%(pos)s" % {
"toolpath": toolpath,
"file_path": file_path,
"pos": pos,
"guru_json": guru_json,
"mode": mode,
"scope": guru_scope,
"tags": guru_tags,
"contents_size": contents_size,
"contents": contents,
"tags": guru_tags
}
debug("cmd", cmd)

sublime.set_timeout_async(lambda: self.runInThread(cmd, callback, cmd_env), 0)
sublime.set_timeout_async(lambda: self.runInThread(cmd, callback, cmd_env, contents, contents_size, file_path), 0)

def runInThread(self, cmd, callback, env):
def runInThread(self, cmd, callback, env, contents, contents_size, file_path):
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True, env=env)
proc.stdin.write(bytes(file_path+'\n'+contents_size+'\n'+contents, encoding='utf8'))
out, err = proc.communicate()
callback(out.decode('utf-8'), err.decode('utf-8'))

Expand Down

0 comments on commit cac9f73

Please sign in to comment.