Permalink
Browse files

Fix long/float param passing issue in ST2 (ref/cite)

  • Loading branch information...
1 parent f3bcdbf commit 8f1874e43eb08111d3d60206030034e937449d07 @msiniscalchi msiniscalchi committed Jul 18, 2013
Showing with 8 additions and 21 deletions.
  1. +1 −10 latex_cite_completions.py
  2. +7 −2 latex_ref_cite_completions.py
  3. +0 −9 latex_ref_completions.py
View
@@ -156,17 +156,12 @@ def get_cite_completions(view, point, autocompleting=False):
if not preformatted:
# Replace cite_blah with \cite{blah
-# expr_region = sublime.Region(point - len(expr), point)
-# #print expr, view.substr(expr_region)
-# ed = view.begin_edit()
pre_snippet = "\cite" + fancy_cite + "{"
-# view.replace(edit, expr_region, pre_snippet + prefix)
# The "latex_tools_replace" command is defined in latex_ref_cite_completions.py
view.run_command("latex_tools_replace", {"a": point-len(expr), "b": point, "replacement": pre_snippet + prefix})
# save prefix begin and endpoints points
new_point_a = point - len(expr) + len(pre_snippet)
new_point_b = new_point_a + len(prefix)
-# view.end_edit(ed)
else:
# Don't include post_brace if it's already present
@@ -445,13 +440,9 @@ def on_done(i):
cite = completions[i][0] + post_brace
- print("DEBUG: types of new_point_a and new_point_b are " + repr(type(new_point_a)) + " and " + repr(type(new_point_b)))
+ #print("DEBUG: types of new_point_a and new_point_b are " + repr(type(new_point_a)) + " and " + repr(type(new_point_b)))
# print "selected %s:%s by %s" % completions[i][0:3]
# Replace cite expression with citation
- expr_region = sublime.Region(new_point_a, new_point_b)
- # ed = view.begin_edit()
- # view.replace(ed, expr_region, cite)
- # view.end_edit(ed)
# the "latex_tools_replace" command is defined in latex_ref_cite_completions.py
view.run_command("latex_tools_replace", {"a": new_point_a, "b": new_point_b, "replacement": cite})
# Unselect the replaced region and leave the caret at the end
@@ -86,6 +86,11 @@ def run(self, edit, insert_char=""):
# Used by both cite and ref completion
class LatexToolsReplaceCommand(sublime_plugin.TextCommand):
def run(self, edit, a, b, replacement):
- print("DEBUG: types of a and b are " + repr(type(a)) + " and " + repr(type(b)))
- region = sublime.Region(a, b)
+ #print("DEBUG: types of a and b are " + repr(type(a)) + " and " + repr(type(b)))
+ # On ST2, a and b are passed as long, but received as floats
+ # It's probably a bug. Convert to be safe.
+ if _ST3:
+ region = sublime.Region(a, b)
+ else:
+ region = sublime.Region(long(a), long(b))
self.view.replace(edit, region, replacement)
View
@@ -140,10 +140,6 @@ def get_ref_completions(view, point, autocompleting=False):
if not preformatted:
# Replace ref_blah with \ref{blah
-# expr_region = sublime.Region(point - len(expr), point)
- #print expr[::-1], view.substr(expr_region)
-# ed = view.begin_edit()
-# view.replace(ed, expr_region, pre_snippet + prefix)
# The "latex_tools_replace" command is defined in latex_ref_cite_completions.py
view.run_command("latex_tools_replace", {"a": point-len(expr), "b": point, "replacement": pre_snippet + prefix})
# save prefix begin and endpoints points
@@ -255,12 +251,7 @@ def on_done(i):
ref = completions[i] + post_snippet
- # print "selected %s" % completions[i]
# Replace ref expression with reference and possibly post_snippet
- # expr_region = sublime.Region(new_point_a,new_point_b)
- # ed = view.begin_edit()
- # view.replace(ed, expr_region, ref)
- # view.end_edit(ed)
# The "latex_tools_replace" command is defined in latex_ref_cite_completions.py
view.run_command("latex_tools_replace", {"a": new_point_a, "b": new_point_b, "replacement": ref})
# Unselect the replaced region and leave the caret at the end

0 comments on commit 8f1874e

Please sign in to comment.