diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorSmartKeysConfigurable.form b/platform/lang-impl/src/com/intellij/application/options/editor/EditorSmartKeysConfigurable.form index b69087962ab0..f9cb5da0f632 100644 --- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorSmartKeysConfigurable.form +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorSmartKeysConfigurable.form @@ -160,6 +160,7 @@ + diff --git a/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightSettings.java b/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightSettings.java index 1b7003239c3e..013b0808faca 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightSettings.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/CodeInsightSettings.java @@ -100,7 +100,7 @@ public class CodeInsightSettings implements PersistentStateComponent, C public boolean SHOW_FULL_SIGNATURES_IN_PARAMETER_INFO = false; - public boolean INDENTING_BACKSPACE = false; + public boolean INDENTING_BACKSPACE = true; public boolean SMART_INDENT_ON_ENTER = true; public boolean INSERT_BRACE_ON_ENTER = true; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java index b98fe4a6b985..36c13aad6040 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionProgressIndicator.java @@ -759,8 +759,8 @@ public class CompletionProgressIndicator extends ProgressIndicatorBase implement catch (ProcessCanceledException ignore) { } catch (Throwable t) { - LOG.error(t); cancel(); + LOG.error(t); } } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/IndentingBackspaceHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/IndentingBackspaceHandler.java index f10c13a7740f..a4f34c49a6bb 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/IndentingBackspaceHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/IndentingBackspaceHandler.java @@ -23,6 +23,7 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileTypes.FileType; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider; @@ -35,13 +36,16 @@ import org.jetbrains.annotations.NotNull; public class IndentingBackspaceHandler extends BackspaceHandlerDelegate { private static final Logger LOG = Logger.getInstance(IndentingBackspaceHandler.class); + private boolean caretWasAtLineStart; + @Override public void beforeCharDeleted(char c, PsiFile file, Editor editor) { + caretWasAtLineStart = editor.getCaretModel().getLogicalPosition().column == 0; } @Override public boolean charDeleted(char c, PsiFile file, Editor editor) { - if (!CodeInsightSettings.getInstance().INDENTING_BACKSPACE || " \n\t".indexOf(c) == -1) { + if (!CodeInsightSettings.getInstance().INDENTING_BACKSPACE || !StringUtil.isWhiteSpace(c)) { return false; } LanguageCodeStyleSettingsProvider codeStyleSettingsProvider = LanguageCodeStyleSettingsProvider.forLanguage(file.getLanguage()); @@ -51,12 +55,13 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate { Document document = editor.getDocument(); - int offset = CharArrayUtil.shiftForward(document.getCharsSequence(), editor.getCaretModel().getOffset(), " \t"); + int caretOffset = editor.getCaretModel().getOffset(); + int offset = CharArrayUtil.shiftForward(document.getCharsSequence(), caretOffset, " \t"); int beforeWhitespaceOffset = CharArrayUtil.shiftBackward(document.getCharsSequence(), offset - 1, " \t") + 1; - LogicalPosition logicalPosition = editor.offsetToLogicalPosition(offset); + LogicalPosition logicalPosition = caretOffset < offset ? editor.offsetToLogicalPosition(offset) : editor.getCaretModel().getLogicalPosition(); int lineStartOffset = document.getLineStartOffset(logicalPosition.line); if (lineStartOffset < beforeWhitespaceOffset) { - if (c == '\n' && beforeWhitespaceOffset < offset) { + if (caretWasAtLineStart && beforeWhitespaceOffset < offset) { document.deleteString(beforeWhitespaceOffset, offset); return true; } @@ -75,11 +80,18 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate { int targetColumn = getWidth(indent, tabSize); if (logicalPosition.column == targetColumn) { - return false; + if (caretOffset < offset) { + editor.getCaretModel().moveToLogicalPosition(logicalPosition); + return true; + } + else { + return false; + } } - if (c == '\n' || logicalPosition.column > targetColumn) { + if (caretWasAtLineStart || logicalPosition.column > targetColumn) { smartReplace(document, lineStartOffset, offset, indent); + editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(logicalPosition.line, targetColumn)); return true; } @@ -93,9 +105,11 @@ public class IndentingBackspaceHandler extends BackspaceHandlerDelegate { if (prevLineStartOffset < targetOffset) { document.deleteString(targetOffset, offset); + editor.getCaretModel().moveToOffset(targetOffset); } else { smartReplace(document, prevLineStartOffset, offset, indent); + editor.getCaretModel().moveToLogicalPosition(new LogicalPosition(logicalPosition.line - 1, targetColumn)); } return true; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupUi.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupUi.java index c1f2c6a89ab1..b1b0c8434ebb 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupUi.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/LookupUi.java @@ -377,18 +377,18 @@ class LookupUi { myScrollBarIncreaseButton.setPreferredSize(buttonSize); myScrollBarIncreaseButton.setMinimumSize(buttonSize); myScrollBarIncreaseButton.setMaximumSize(buttonSize); - JScrollBar scrollBar = myScrollPane.getVerticalScrollBar(); - scrollBar.revalidate(); - scrollBar.repaint(); - + JScrollBar vScrollBar = myScrollPane.getVerticalScrollBar(); + vScrollBar.revalidate(); + vScrollBar.repaint(); + final Dimension iconSize = myProcessIcon.getPreferredSize(); - myIconPanel.setBounds(getWidth() - iconSize.width - (scrollBar.isVisible() ? scrollBar.getWidth() : 0), 0, iconSize.width, iconSize.height); + myIconPanel.setBounds(getWidth() - iconSize.width - (vScrollBar.isVisible() ? vScrollBar.getWidth() : 0), 0, iconSize.width, + iconSize.height); final Dimension sortSize = mySortingLabel.getPreferredSize(); - final Point sbLocation = SwingUtilities.convertPoint(scrollBar, 0, 0, myLayeredPane); - - final int sortHeight = Math.max(adHeight, mySortingLabel.getPreferredSize().height); - mySortingLabel.setBounds(sbLocation.x, getHeight() - sortHeight, sortSize.width, sortHeight); + final int sortWidth = vScrollBar.isVisible() ? vScrollBar.getWidth() : sortSize.width; + final int sortHeight = Math.max(sortSize.height, adHeight); + mySortingLabel.setBounds(getWidth() - sortWidth, getHeight() - sortHeight, sortSize.width, sortHeight); } void layoutHint() { diff --git a/platform/lang-impl/testData/editor/indentingBackspace/caretAheadOfText2-after.java b/platform/lang-impl/testData/editor/indentingBackspace/caretAheadOfText2-after.java index e8c58612a4db..7180cd368c25 100644 --- a/platform/lang-impl/testData/editor/indentingBackspace/caretAheadOfText2-after.java +++ b/platform/lang-impl/testData/editor/indentingBackspace/caretAheadOfText2-after.java @@ -1,3 +1,3 @@ class Foo { - int field; + int field; } \ No newline at end of file diff --git a/platform/lang-impl/testData/editor/indentingBackspace/caretAheadOfText3-after.java b/platform/lang-impl/testData/editor/indentingBackspace/caretAheadOfText3-after.java index 6aa58a6ac8b1..7180cd368c25 100644 --- a/platform/lang-impl/testData/editor/indentingBackspace/caretAheadOfText3-after.java +++ b/platform/lang-impl/testData/editor/indentingBackspace/caretAheadOfText3-after.java @@ -1,3 +1,3 @@ class Foo { - int field; + int field; } \ No newline at end of file diff --git a/platform/lang-impl/testData/editor/indentingBackspace/caretAheadOfText4-after.java b/platform/lang-impl/testData/editor/indentingBackspace/caretAheadOfText4-after.java index b77c65948e6f..7180cd368c25 100644 --- a/platform/lang-impl/testData/editor/indentingBackspace/caretAheadOfText4-after.java +++ b/platform/lang-impl/testData/editor/indentingBackspace/caretAheadOfText4-after.java @@ -1,3 +1,3 @@ class Foo { - int field; + int field; } \ No newline at end of file diff --git a/platform/lang-impl/testData/editor/indentingBackspace/emptyLines-after.java b/platform/lang-impl/testData/editor/indentingBackspace/emptyLines-after.java new file mode 100644 index 000000000000..ba5cbf5dcd98 --- /dev/null +++ b/platform/lang-impl/testData/editor/indentingBackspace/emptyLines-after.java @@ -0,0 +1,3 @@ +class Foo { + +} \ No newline at end of file diff --git a/platform/lang-impl/testData/editor/indentingBackspace/emptyLines.java b/platform/lang-impl/testData/editor/indentingBackspace/emptyLines.java new file mode 100644 index 000000000000..04ecf9dceadb --- /dev/null +++ b/platform/lang-impl/testData/editor/indentingBackspace/emptyLines.java @@ -0,0 +1,4 @@ +class Foo { + + +} \ No newline at end of file diff --git a/platform/lang-impl/testSources/com/intellij/codeInsight/editorActions/IndentingBackspaceHandlerTest.java b/platform/lang-impl/testSources/com/intellij/codeInsight/editorActions/IndentingBackspaceHandlerTest.java index 979d4fdee197..009338fa8f7d 100644 --- a/platform/lang-impl/testSources/com/intellij/codeInsight/editorActions/IndentingBackspaceHandlerTest.java +++ b/platform/lang-impl/testSources/com/intellij/codeInsight/editorActions/IndentingBackspaceHandlerTest.java @@ -15,7 +15,6 @@ */ package com.intellij.codeInsight.editorActions; -import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.openapi.application.Result; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.testFramework.FileBasedTestCaseHelper; @@ -23,8 +22,6 @@ import com.intellij.testFramework.LightPlatformCodeInsightTestCase; import com.intellij.testFramework.TestDataPath; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.junit.After; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,19 +29,6 @@ import org.junit.runner.RunWith; @RunWith(com.intellij.testFramework.Parameterized.class) @TestDataPath("/testData/../../../platform/lang-impl/testData/editor/indentingBackspace/") public class IndentingBackspaceHandlerTest extends LightPlatformCodeInsightTestCase implements FileBasedTestCaseHelper { - private boolean mySavedConfigurationState; - - @Before - public void enableIndentingBackspace() { - mySavedConfigurationState = CodeInsightSettings.getInstance().INDENTING_BACKSPACE; - CodeInsightSettings.getInstance().INDENTING_BACKSPACE = true; - } - - @After - public void restoreSettings() { - CodeInsightSettings.getInstance().INDENTING_BACKSPACE = mySavedConfigurationState; - } - @Test public void testAction() { new WriteCommandAction(null) { diff --git a/platform/lang-impl/testSources/com/intellij/codeInsight/editorActions/IndentingBackspaceHandlerVirtualSpaceTest.java b/platform/lang-impl/testSources/com/intellij/codeInsight/editorActions/IndentingBackspaceHandlerVirtualSpaceTest.java new file mode 100644 index 000000000000..78cf05abe4cb --- /dev/null +++ b/platform/lang-impl/testSources/com/intellij/codeInsight/editorActions/IndentingBackspaceHandlerVirtualSpaceTest.java @@ -0,0 +1,118 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.editorActions; + +import com.intellij.openapi.editor.LogicalPosition; +import com.intellij.testFramework.LightPlatformCodeInsightTestCase; + +import java.io.IOException; + +public class IndentingBackspaceHandlerVirtualSpaceTest extends LightPlatformCodeInsightTestCase { + public void testAfterLargeIndent() throws IOException { + doTest("class Foo {\n" + + " \n" + + "}", + new LogicalPosition(1, 10), + "class Foo {\n" + + " \n" + + "}", + new LogicalPosition(1, 4)); + } + + public void testAfterProperIndent() throws IOException { + doTest("class Foo {\n" + + " \n" + + "}", + new LogicalPosition(1, 10), + "class Foo {\n" + + " \n" + + "}", + new LogicalPosition(1, 4)); + } + + public void testAfterSmallIndent() throws IOException { + doTest("class Foo {\n" + + " \n" + + "}", + new LogicalPosition(1, 10), + "class Foo {\n" + + " \n" + + "}", + new LogicalPosition(1, 4)); + } + + public void testAfterEmptyIndent() throws IOException { + doTest("class Foo {\n" + + "\n" + + "}", + new LogicalPosition(1, 10), + "class Foo {\n" + + " \n" + + "}", + new LogicalPosition(1, 4)); + } + + public void testAtIndent() throws IOException { + doTest("class Foo {\n" + + " \n" + + "}", + new LogicalPosition(1, 4), + "class Foo {\n" + + "}", + new LogicalPosition(0, 11)); + } + + public void testAtIndentOnEmptyLine() throws IOException { + doTest("class Foo {\n" + + "\n" + + "}", + new LogicalPosition(1, 4), + "class Foo {\n" + + "}", + new LogicalPosition(0, 11)); + } + + public void testBeforeIndent() throws IOException { + doTest("class Foo {\n" + + " \n" + + "}", + new LogicalPosition(1, 3), + "class Foo {\n" + + "}", + new LogicalPosition(0, 11)); + } + + public void testDeleteLine() throws IOException { + doTest("class Foo {\n" + + "\n" + + "\n" + + "}", + new LogicalPosition(2, 0), + "class Foo {\n" + + " \n" + + "}", + new LogicalPosition(1, 4)); + } + + private void doTest(String textBefore, LogicalPosition caretBefore, String textAfter, LogicalPosition caretAfter) throws IOException { + configureFromFileText(getTestName(false) + ".java", textBefore); + myEditor.getSettings().setVirtualSpace(true); + myEditor.getCaretModel().moveToLogicalPosition(caretBefore); + backspace(); + checkResultByText(textAfter); + assertEquals(caretAfter, myEditor.getCaretModel().getLogicalPosition()); + } +} diff --git a/platform/platform-impl/src/com/intellij/ide/util/TipUIUtil.java b/platform/platform-impl/src/com/intellij/ide/util/TipUIUtil.java index f8c1029e0a97..bbd52139bd51 100644 --- a/platform/platform-impl/src/com/intellij/ide/util/TipUIUtil.java +++ b/platform/platform-impl/src/com/intellij/ide/util/TipUIUtil.java @@ -92,8 +92,11 @@ public class TipUIUtil { updateShortcuts(text); updateImages(text, tipLoader); String replaced = text.toString().replace("&productName;", ApplicationNamesInfo.getInstance().getFullProductName()); - replaced = replaced.replace("&majorVersion;", ApplicationInfo.getInstance().getMajorVersion()); - replaced = replaced.replace("&minorVersion;", ApplicationInfo.getInstance().getMinorVersion()); + String major = ApplicationInfo.getInstance().getMajorVersion(); + replaced = replaced.replace("&majorVersion;", major); + String minor = ApplicationInfo.getInstance().getMinorVersion(); + replaced = replaced.replace("&minorVersion;", minor); + replaced = replaced.replace("&majorMinorVersion;", major + ("0".equals(minor) ? "" : ("." + minor))); if (UIUtil.isUnderDarcula()) { replaced = replaced.replace("css/tips.css", "css/tips_darcula.css"); } diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java index f3e7da762f91..db70a97929d7 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java @@ -35,6 +35,7 @@ import com.intellij.openapi.wm.IdeFrame; import com.intellij.openapi.wm.WindowManager; import com.intellij.openapi.wm.ex.ProgressIndicatorEx; import com.intellij.openapi.wm.ex.StatusBarEx; +import com.intellij.psi.impl.DebugUtil; import com.intellij.ui.AppIcon; import com.intellij.util.concurrency.Semaphore; import com.intellij.util.containers.ContainerUtil; @@ -82,6 +83,7 @@ public class DumbServiceImpl extends DumbService implements Disposable { @Override public void cancelTask(@NotNull DumbModeTask task) { + if (ApplicationManager.getApplication().isInternal()) LOG.info("cancel " + task + "\n" + DebugUtil.currentStackTrace()); ProgressIndicatorEx indicator = myProgresses.get(task); if (indicator != null) { indicator.cancel(); @@ -143,6 +145,7 @@ public class DumbServiceImpl extends DumbService implements Disposable { } private void scheduleCacheUpdate(@NotNull final DumbModeTask task, boolean forceDumbMode) { + if (ApplicationManager.getApplication().isInternal()) LOG.info("schedule " + task); final Application application = ApplicationManager.getApplication(); if (application.isUnitTestMode() || diff --git a/plugins/devkit/src/inspections/quickfix/PluginDescriptorChooser.java b/plugins/devkit/src/inspections/quickfix/PluginDescriptorChooser.java index e701055d07a2..7b4068b1145a 100644 --- a/plugins/devkit/src/inspections/quickfix/PluginDescriptorChooser.java +++ b/plugins/devkit/src/inspections/quickfix/PluginDescriptorChooser.java @@ -72,7 +72,7 @@ public class PluginDescriptorChooser { List> elements = DomService.getInstance().getFileElements(IdeaPlugin.class, project, - module.getModuleContentWithDependenciesScope()); + module.getModuleWithDependenciesScope()); elements = ContainerUtil.filter(elements, new Condition>() { @Override diff --git a/resources-en/src/search/searchableOptions.xml b/resources-en/src/search/searchableOptions.xml index f0c1983a67c2..86e76b805242 100644 --- a/resources-en/src/search/searchableOptions.xml +++ b/resources-en/src/search/searchableOptions.xml @@ -22334,6 +22334,9 @@