diff --git a/recaf-ui/src/main/java/software/coley/recaf/ui/pane/editing/assembler/AssemblerPane.java b/recaf-ui/src/main/java/software/coley/recaf/ui/pane/editing/assembler/AssemblerPane.java index e54dc8cb1..213460a46 100644 --- a/recaf-ui/src/main/java/software/coley/recaf/ui/pane/editing/assembler/AssemblerPane.java +++ b/recaf-ui/src/main/java/software/coley/recaf/ui/pane/editing/assembler/AssemblerPane.java @@ -28,6 +28,7 @@ import software.coley.recaf.util.FxThreadUtil; import software.coley.recaf.workspace.model.bundle.Bundle; +import java.time.Duration; import java.util.Collection; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -49,7 +50,6 @@ public class AssemblerPane extends AbstractContentPane> implements U private List lastRoughAst; private List lastPartialAst; private List lastAst; - private long lastAstParse = 0; @Inject public AssemblerPane(@Nonnull AssemblerPipelineManager pipelineManager, @@ -67,7 +67,9 @@ public AssemblerPane(@Nonnull AssemblerPipelineManager pipelineManager, new ProblemGraphicFactory() ); - this.editor.getTextChangeEventStream().subscribe(event -> parseAST(ast -> {})); + this.editor.getTextChangeEventStream().successionEnds(Duration.ofMillis(timeToWait)).addObserver(e -> { + parseAST(ast -> {}); + }); this.pipelineManager.getServiceConfig().getDisassemblyAstParseDelay().addChangeListener( (observable, oldVal, newVal) -> timeToWait = newVal); @@ -102,8 +104,7 @@ private void disassemble() { private void parseAST(Consumer> acceptor) { if(editor.getText().isBlank()) return; - if(lastAstParse > System.currentTimeMillis() - timeToWait) return; - lastAstParse = System.currentTimeMillis(); + CompletableFuture.runAsync(() -> { try { problemTracking.removeByPhase(ProblemPhase.LINT); @@ -137,10 +138,10 @@ private void assemble() { return; CompletableFuture.runAsync(() -> { try { - if(lastAst == null || lastAstParse < System.currentTimeMillis() - timeToWait) { - parseAST(ast -> assemble()); + parseAST(ast -> {}); + + if(!problemTracking.getProblems().isEmpty() && lastAst == null) return; - } problemTracking.removeByPhase(ProblemPhase.BUILD);