Skip to content

Commit

Permalink
Fix state.is_dirty() when all colored regions in a file were deleted …
Browse files Browse the repository at this point in the history
…(no matches with regexps after there actually were a few)
  • Loading branch information
FichteFoll committed Apr 19, 2012
1 parent f60f629 commit ccf3b8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 0 additions & 2 deletions livecss/colorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ def colorize_file(view, state, forse_redraw=False):

colored_regions = get_colored_regions(view)
colors = get_colors(view, colored_regions)
if not colors:
return

state.colors = colors
state.regions = colored_regions
Expand Down
11 changes: 3 additions & 8 deletions livecss/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,15 @@ def __init__(self, view):
def is_dirty(self):
"""Indicates if state was changed"""

# if we don't have previously saved state
if not self.regions:
print "no regions! lol"
return True

highlighted_regions = get_highlighted_regions(self.view, self.count)

# check if regions have changed
if highlighted_regions == self.regions:
if highlighted_regions == self.regions or (not self.regions and not highlighted_regions):
is_dirty = False
else:
is_dirty = True

# check if length of regions changed
# check if lengths of regions changed
if not is_dirty:
for reg_pair in zip(self.saved_regions, self.regions):
if abs(reg_pair[0].a - reg_pair[0].b) != abs(reg_pair[1].a - reg_pair[1].b):
Expand Down Expand Up @@ -67,7 +62,7 @@ def get_highlighted_regions(view, last_highlighted_region):
if not last_highlighted_region:
return
regions = []
for i in range(int(last_highlighted_region)):
for i in range(last_highlighted_region):
region = view.get_regions('css_color_%d' % i)
if region:
regions.append(region[0])
Expand Down

0 comments on commit ccf3b8b

Please sign in to comment.