Skip to content

Commit

Permalink
Block paragraph list updates while being updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasMikula committed May 12, 2014
1 parent 3cdc169 commit cf17d75
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions richtextfx/src/main/java/org/fxmisc/richtext/StyledTextArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import javafx.beans.value.ObservableIntegerValue;
import javafx.beans.value.ObservableStringValue;
import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList;
import javafx.css.CssMetaData;
import javafx.css.Styleable;
import javafx.css.StyleableObjectProperty;
Expand All @@ -48,6 +47,8 @@
import org.reactfx.Guardian;
import org.reactfx.Indicator;
import org.reactfx.InterceptableEventStream;
import org.reactfx.inhibeans.collection.Collections;
import org.reactfx.inhibeans.collection.ObservableList;

import com.sun.javafx.Utils;

Expand Down Expand Up @@ -270,7 +271,7 @@ public <C> StyledTextArea(S initialStyle, BiConsumer<Text, S> applyStyle,
this.applyStyle = applyStyle;
this.preserveStyle = preserveStyle;
content = new EditableStyledDocument<>(initialStyle);
paragraphs = content.getParagraphs();
paragraphs = Collections.wrap(content.getParagraphs());

text = org.reactfx.inhibeans.binding.Binding.wrap(content.textProperty());
length = org.reactfx.inhibeans.binding.IntegerBinding.wrap(content.lengthProperty());
Expand Down Expand Up @@ -317,9 +318,12 @@ public <C> StyledTextArea(S initialStyle, BiConsumer<Text, S> applyStyle,
currentParagraph,
caretColumn,

// add streams as last ones, to be the first ones to release
// add streams after properties, to be released before them
plainTextChanges::pause,
richTextChanges::pause);
richTextChanges::pause,

// paragraphs to be released first
paragraphs);

this.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
getStyleClass().add("styled-text-area");
Expand Down

0 comments on commit cf17d75

Please sign in to comment.