Skip to content

Commit

Permalink
Add MateText#delay_parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
danlucraft committed Mar 2, 2010
1 parent 7ef9015 commit b8c772d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/java-mateview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def set_root_scope_by_content_name(grammar_name, name)
scope.isOpen = true
self.parser.root = scope
end

def delay_parsing
parser.deactivate
yield
parser.reactivate
end
end
end

Expand Down
15 changes: 14 additions & 1 deletion src/com/redcareditor/mate/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ public void modifyEventCallback() {
modifyStart = -1;
modifyEnd = -1;
modifyText = null;
processChanges();
if (deactivationLevel == 0)
processChanges();
}
}

Expand All @@ -225,6 +226,18 @@ public void viewportScrolledCallback() {
}
}

public void deactivate() {
deactivationLevel++;
}

public void reactivate() {
deactivationLevel--;
if (deactivationLevel < 0)
deactivationLevel = 0;
if (deactivationLevel == 0)
processChanges();
}

// Process all change ranges.
public void processChanges() {
int thisParsedUpto = -1;
Expand Down

0 comments on commit b8c772d

Please sign in to comment.