Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop TerminalExecutionConole double echoing input in 2018.2 and 2018.2.1 #1208

Merged
merged 2 commits into from
Aug 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ matrix:
include:
# version groups based on https://www.jetbrains.com/idea/download/previous.html

- elixir: 1.6.5
env: IDEA_VERSION="2018.2"
- elixir: 1.6.6
env: IDEA_VERSION="2018.2.1"
jdk: oraclejdk8
otp_release: 20.1
- elixir: 1.5.3
env: IDEA_VERSION="2018.2"
env: IDEA_VERSION="2018.2.1"
jdk: oraclejdk8
otp_release: 20.1

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# https://www.jetbrains.com/intellij-repository/snapshots

version = 8.0.0
ideaVersion = 2018.2
ideaVersion = 2018.2.1
javaVersion = 1.8
javaTargetVersion = 1.8
sources = true
Expand Down
2 changes: 1 addition & 1 deletion src/org/elixir_lang/distillery/State.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.intellij.execution.ui.ConsoleView
import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import com.intellij.notification.Notifications
import com.intellij.terminal.TerminalExecutionConsole
import org.elixir_lang.run.TerminalExecutionConsole
import org.elixir_lang.console.ElixirConsoleUtil
import org.elixir_lang.utils.SetupElixirSDKNotificationListener

Expand Down
2 changes: 1 addition & 1 deletion src/org/elixir_lang/iex/State.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.intellij.execution.runners.ProgramRunner
import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import com.intellij.notification.Notifications
import com.intellij.terminal.TerminalExecutionConsole
import org.elixir_lang.run.TerminalExecutionConsole
import org.elixir_lang.console.ElixirConsoleUtil
import org.elixir_lang.utils.SetupElixirSDKNotificationListener

Expand Down
2 changes: 1 addition & 1 deletion src/org/elixir_lang/iex/mix/State.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.intellij.execution.runners.ProgramRunner
import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import com.intellij.notification.Notifications
import com.intellij.terminal.TerminalExecutionConsole
import org.elixir_lang.run.TerminalExecutionConsole
import org.elixir_lang.console.ElixirConsoleUtil
import org.elixir_lang.utils.SetupElixirSDKNotificationListener

Expand Down
54 changes: 54 additions & 0 deletions src/org/elixir_lang/run/PendingTasksRunner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.elixir_lang.run;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.util.Alarm;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

public class PendingTasksRunner {
private final List<Runnable> myPendingTasks = new ArrayList<>();
private final AtomicBoolean myReady = new AtomicBoolean(false);
private final Alarm myAlarm;

public PendingTasksRunner(long awaitTimeout, @NotNull Project project) {
myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, project);
myAlarm.addRequest(() -> setReady(), awaitTimeout);
}

public void execute(@NotNull Runnable task) {
if (myReady.get()) {
task.run();
}
else {
synchronized (myPendingTasks) {
myPendingTasks.add(task);
}
if (myReady.get()) {
runPendingTasks();
}
}
}

public void setReady() {
if (myReady.compareAndSet(false, true)) {
Disposer.dispose(myAlarm);
runPendingTasks();
}
}

private void runPendingTasks() {
List<Runnable> tasks;
synchronized (myPendingTasks) {
tasks = new ArrayList<>(myPendingTasks);
myPendingTasks.clear();
}
for (Runnable task : tasks) {
task.run();
}
}
}
Loading