Skip to content

Commit

Permalink
Minor fix to avoid unexpected SWT errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Apr 4, 2014
1 parent a991162 commit 70c14e2
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import org.jboss.tools.aesh.ui.internal.document.StyleImpl;

public class DocumentListenerImpl implements IDocumentListener {

private TextWidget textWidget;
private DocumentImpl document;

public DocumentListenerImpl(TextWidget textWidget, DocumentImpl document) {
this.textWidget = textWidget;
this.document = document;
Expand All @@ -27,10 +27,11 @@ public void documentChanged(final DocumentEvent event) {
textWidget.setTopIndex(lineCount - 1);
StyleImpl style = (StyleImpl)document.getCurrentStyle();
StyleRange styleRange = style.getStyleRange();
if (styleRange != null &&
event.getLength() == 0 &&
styleRange.start <= document.getLength() &&
styleRange.length >= 0 &&
if (styleRange != null &&
event.getLength() == 0 &&
styleRange.start >= 0 &&
styleRange.start <= document.getLength() &&
styleRange.length >= 0 &&
styleRange.start + styleRange.length <= document.getLength()) {
textWidget.setStyleRange(styleRange);
}
Expand Down

0 comments on commit 70c14e2

Please sign in to comment.