mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
terminal: do not show confirmation dialog if terminal was moved to editor
This commit is contained in:
@@ -64,7 +64,6 @@ import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -323,9 +322,14 @@ public class TerminalView {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable
|
||||
public static JBTerminalWidget getWidgetByContent(@NotNull Content content) {
|
||||
return Objects.requireNonNull(content.getUserData(TERMINAL_WIDGET_KEY));
|
||||
return content.getUserData(TERMINAL_WIDGET_KEY);
|
||||
}
|
||||
|
||||
public void detachWidgetAndRemoveContent(@NotNull Content content) {
|
||||
content.putUserData(TERMINAL_WIDGET_KEY, null);
|
||||
myToolWindow.getContentManager().removeContent(content, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-3
@@ -16,15 +16,14 @@ class MoveTerminalSessionToEditorAction : TerminalSessionContextMenuActionBase()
|
||||
val tabInfo = TabInfo(selectedContent!!.component)
|
||||
.setText(selectedContent.displayName)
|
||||
val terminalView = TerminalView.getInstance(e.project!!)
|
||||
val terminalWidget = TerminalView.getWidgetByContent(selectedContent)
|
||||
val terminalWidget = TerminalView.getWidgetByContent(selectedContent)!!
|
||||
val file = TerminalSessionVirtualFileImpl(tabInfo, terminalWidget, terminalView.terminalRunner.settingsProvider)
|
||||
tabInfo.setObject(file)
|
||||
file.putUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN, java.lang.Boolean.TRUE)
|
||||
val fileEditor = FileEditorManager.getInstance(e.project!!).openFile(file, true).first()
|
||||
|
||||
terminalWidget.moveDisposable(fileEditor)
|
||||
|
||||
activeToolWindow.contentManager.removeContent(selectedContent, true)
|
||||
terminalView.detachWidgetAndRemoveContent(selectedContent)
|
||||
|
||||
file.putUserData(FileEditorManagerImpl.CLOSING_TO_REOPEN, null)
|
||||
}
|
||||
|
||||
+2
-1
@@ -77,10 +77,11 @@ public class TerminalArrangementManager implements PersistentStateComponent<Term
|
||||
TerminalArrangementState arrangementState = new TerminalArrangementState();
|
||||
ContentManager contentManager = terminalToolWindow.getContentManager();
|
||||
for (Content content : contentManager.getContents()) {
|
||||
JBTerminalWidget terminalWidget = TerminalView.getWidgetByContent(content);
|
||||
if (terminalWidget == null) continue;
|
||||
TerminalTabState tabState = new TerminalTabState();
|
||||
tabState.myTabName = content.getTabName();
|
||||
tabState.myWorkingDirectory = myWorkingDirectoryManager.getWorkingDirectory(content);
|
||||
JBTerminalWidget terminalWidget = TerminalView.getWidgetByContent(content);
|
||||
String historyFilePath = terminalWidget.getCommandHistoryFilePath();
|
||||
tabState.myCommandHistoryFileName = historyFilePath != null ? PathUtil.getFileName(historyFilePath) : null;
|
||||
arrangementState.myTabStates.add(tabState);
|
||||
|
||||
+7
-2
@@ -24,6 +24,7 @@ import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -81,12 +82,14 @@ public class TerminalWorkingDirectoryManager {
|
||||
data.myWorkingDirectory = content.getUserData(INITIAL_CWD_KEY);
|
||||
content.putUserData(INITIAL_CWD_KEY, null);
|
||||
dataRef.set(data);
|
||||
TerminalView.getWidgetByContent(content).getTerminalPanel().addCustomKeyListener(listener);
|
||||
JBTerminalWidget widget = Objects.requireNonNull(TerminalView.getWidgetByContent(content));
|
||||
widget.getTerminalPanel().addCustomKeyListener(listener);
|
||||
myDataByContentMap.put(content, data);
|
||||
}
|
||||
|
||||
private static void updateWorkingDirectory(@NotNull Content content, @NotNull Data data) {
|
||||
JBTerminalWidget widget = TerminalView.getWidgetByContent(content);
|
||||
if (widget == null) return;
|
||||
ProcessTtyConnector connector = ObjectUtils.tryCast(widget.getTtyConnector(), ProcessTtyConnector.class);
|
||||
if (connector == null) return;
|
||||
try {
|
||||
@@ -118,7 +121,9 @@ public class TerminalWorkingDirectoryManager {
|
||||
if (data != null) {
|
||||
myDataByContentMap.remove(content);
|
||||
JBTerminalWidget widget = TerminalView.getWidgetByContent(content);
|
||||
widget.getTerminalPanel().removeCustomKeyListener(data.myKeyListener);
|
||||
if (widget != null) {
|
||||
widget.getTerminalPanel().removeCustomKeyListener(data.myKeyListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user