From 37d1a1e7231ad91c499868aa8e01aa3bd8c0786c Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Fri, 1 Apr 2011 13:08:19 +0400 Subject: [PATCH 1/4] Fixed bug with history stop working after executing empty last history item (PY-3232). --- .../execution/runners/ConsoleExecuteActionHandler.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/execution/runners/ConsoleExecuteActionHandler.java b/platform/lang-impl/src/com/intellij/execution/runners/ConsoleExecuteActionHandler.java index 8b0db9e4694d..3e3c1f8e5ccd 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/ConsoleExecuteActionHandler.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/ConsoleExecuteActionHandler.java @@ -60,9 +60,8 @@ public class ConsoleExecuteActionHandler { languageConsole.addCurrentToHistory(range, false, myPreserveMarkup); } languageConsole.setInputText(""); - if (!StringUtil.isEmptyOrSpaces(text)) { - myConsoleHistoryModel.addToHistory(text); - } + + myConsoleHistoryModel.addToHistory(text); // Send to interpreter / server processLine(text); From fb1dc921bb5f23adbac96a8f71159aeae489e869 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Fri, 1 Apr 2011 16:31:58 +0400 Subject: [PATCH 2/4] NPE fixed. --- .../src/com/intellij/openapi/module/ModuleServiceManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-api/src/com/intellij/openapi/module/ModuleServiceManager.java b/platform/lang-api/src/com/intellij/openapi/module/ModuleServiceManager.java index 3ad759137240..da0c3855fa0f 100644 --- a/platform/lang-api/src/com/intellij/openapi/module/ModuleServiceManager.java +++ b/platform/lang-api/src/com/intellij/openapi/module/ModuleServiceManager.java @@ -16,6 +16,8 @@ package com.intellij.openapi.module; +import org.jetbrains.annotations.NotNull; + /** * @author yole */ @@ -23,7 +25,7 @@ public class ModuleServiceManager { private ModuleServiceManager() { } - public static T getService(Module module, Class serviceClass) { + public static T getService(@NotNull Module module, @NotNull Class serviceClass) { return (T)module.getPicoContainer().getComponentInstance(serviceClass.getName()); } } \ No newline at end of file From 983f99eb0d4898d3c4aa06880b965be1973ba68e Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Tue, 5 Apr 2011 10:53:07 +0400 Subject: [PATCH 3/4] Fixed bug with empty string adding (PY-3232). --- .../execution/process/ConsoleHistoryModel.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/execution/process/ConsoleHistoryModel.java b/platform/platform-impl/src/com/intellij/execution/process/ConsoleHistoryModel.java index 0e562906b9d4..385b0bb2d862 100644 --- a/platform/platform-impl/src/com/intellij/execution/process/ConsoleHistoryModel.java +++ b/platform/platform-impl/src/com/intellij/execution/process/ConsoleHistoryModel.java @@ -2,6 +2,7 @@ package com.intellij.execution.process; import com.intellij.ide.ui.UISettings; import com.intellij.openapi.util.ModificationTracker; +import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -21,11 +22,14 @@ public class ConsoleHistoryModel implements ModificationTracker { public void addToHistory(final String statement) { final int maxHistorySize = getMaxHistorySize(); synchronized (myHistory) { - removeFromHistory(statement); - if (myHistory.size() >= maxHistorySize) { - myHistory.removeLast(); + myHistoryCursor = -1; + if (!StringUtil.isEmptyOrSpaces(statement)) { + removeFromHistory(statement); + if (myHistory.size() >= maxHistorySize) { + myHistory.removeLast(); + } + myHistory.addFirst(statement); } - myHistory.addFirst(statement); } } @@ -36,7 +40,7 @@ public class ConsoleHistoryModel implements ModificationTracker { public void removeFromHistory(final String statement) { synchronized (myHistory) { myModificationTracker++; - myHistoryCursor = -1; + myHistory.remove(statement); } } From b71b80db234d25caa3e1cfa23505f2f5ee1d4035 Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 5 Apr 2011 20:03:03 +0400 Subject: [PATCH 4/4] remove only added highlighter --- .../internal/psiView/PsiViewerDialog.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java b/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java index 1dd56eedd869..09974f4929db 100644 --- a/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java +++ b/platform/lang-impl/src/com/intellij/internal/psiView/PsiViewerDialog.java @@ -646,6 +646,7 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider { private class MyTreeSelectionListener implements TreeSelectionListener { private final TextAttributes myAttributes; + private RangeHighlighter myHighlighter; public MyTreeSelectionListener() { myAttributes = new TextAttributes(); @@ -656,11 +657,8 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider { public void valueChanged(TreeSelectionEvent e) { if (!myEditor.getDocument().getText().equals(myLastParsedText)) return; TreePath path = myTree.getSelectionPath(); - if (path == null) { - clearSelection(); - } - else { - clearSelection(); + clearSelection(); + if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); if (!(node.getUserObject() instanceof ViewerNodeDescriptor)) return; ViewerNodeDescriptor descriptor = (ViewerNodeDescriptor)node.getUserObject(); @@ -684,8 +682,7 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider { final int textLength = myEditor.getDocument().getTextLength(); if (end <= textLength) { - myEditor.getMarkupModel() - .addRangeHighlighter(start, end, HighlighterLayer.LAST, myAttributes, HighlighterTargetArea.EXACT_RANGE); + myHighlighter = myEditor.getMarkupModel().addRangeHighlighter(start, end, HighlighterLayer.LAST, myAttributes, HighlighterTargetArea.EXACT_RANGE); if (myTree.hasFocus()) { myEditor.getCaretModel().moveToOffset(start); myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); @@ -716,7 +713,10 @@ public class PsiViewerDialog extends DialogWrapper implements DataProvider { } private void clearSelection() { - myEditor.getMarkupModel().removeAllHighlighters(); + if (myHighlighter != null) { + myEditor.getMarkupModel().removeHighlighter(myHighlighter); + myHighlighter.dispose(); + } } }