Skip to content

Commit

Permalink
#31 fixes in apply_integer
Browse files Browse the repository at this point in the history
  • Loading branch information
rmaksim committed Dec 17, 2013
1 parent 3ab6ec0 commit 35ea866
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#Inc-Dec-Value

**v0.1.11** - [#31](https://github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value/issues/31) ST3: Getting TypeError in console when using the number inc/dec functions

**v0.1.10** - [#31](https://github.com/rmaksim/Sublime-Text-2-Inc-Dec-Value/issues/31) ST3: Getting TypeError in console when using the number inc/dec functions

**v0.1.9** - Fixed apply_integer (x -> -x when cursor before x)
Expand Down
8 changes: 4 additions & 4 deletions inc_dec_value.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'''
Inc-Dec-Value v0.1.10
Inc-Dec-Value v0.1.11
Increase / Decrease of
- numbers (integer and fractional),
Expand Down Expand Up @@ -284,7 +284,6 @@ def apply_integer(self):
prev = self.prev()

tmp_reg = self.word_reg
orig_int = self.get_word(tmp_reg)

if prev['sym'] == "-":
tmp_reg = sublime.Region(prev['pos'], self.word_reg.end())
Expand All @@ -293,12 +292,13 @@ def apply_integer(self):
match = re.match('(-*[0-9]+)([a-zA-Z%]+)?$', word)

if match:
result = int(match.group(1)) + self.delta
orig_int = int(match.group(1))
result = orig_int + self.delta
match2 = match.group(2) or ""
self.replace(str(result) + match2, tmp_reg)

pos = self.view.sel()[self.region_index]
if int(orig_int) >= 0 and result < 0 and pos.a == tmp_reg.a:
if orig_int >= 0 and result < 0 and pos.a == tmp_reg.a:
self.view.sel().subtract(tmp_reg)
self.view.sel().add(sublime.Region(tmp_reg.a+1, tmp_reg.a+1))

Expand Down

0 comments on commit 35ea866

Please sign in to comment.