Skip to content
This repository has been archived by the owner on Jun 18, 2018. It is now read-only.

Commit

Permalink
Fix TokenHierarchy problem for NB7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
junichi11 committed Feb 15, 2013
1 parent 7219774 commit 27ecb47
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/org/lorenzos/zencoding/zeneditor/ZenEditor.java
Expand Up @@ -4,6 +4,7 @@
import java.awt.Rectangle;
import javax.swing.JEditorPane;
import javax.swing.JOptionPane;
import javax.swing.text.AbstractDocument;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
Expand Down Expand Up @@ -192,15 +193,21 @@ private void setup() throws ZenEditorException {
String cTemp;

// Get content type
TokenSequence tokenSequence = TokenHierarchy.get(this.doc).tokenSequence();
while (tokenSequence != null) {
tokenSequence.move(this.caretPosition - 1);
if (tokenSequence.moveNext()) {
this.setContentType(tokenSequence.language().mimeType());
tokenSequence = tokenSequence.embedded();
} else {
tokenSequence = null;
AbstractDocument abstractDoc = (AbstractDocument) doc;
abstractDoc.readLock();
try{
TokenSequence tokenSequence = TokenHierarchy.get(this.doc).tokenSequence();
while (tokenSequence != null) {
tokenSequence.move(this.caretPosition - 1);
if (tokenSequence.moveNext()) {
this.setContentType(tokenSequence.language().mimeType());
tokenSequence = tokenSequence.embedded();
} else {
tokenSequence = null;
}
}
} finally {
abstractDoc.readUnlock();
}

// Search for line start
Expand Down

0 comments on commit 27ecb47

Please sign in to comment.