diff --git a/platform/lang-api/src/com/intellij/codeInsight/editorActions/TabOutScopesTracker.java b/platform/lang-api/src/com/intellij/codeInsight/editorActions/TabOutScopesTracker.java index 86ebfb659bf5..37ec18fd3735 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/editorActions/TabOutScopesTracker.java +++ b/platform/lang-api/src/com/intellij/codeInsight/editorActions/TabOutScopesTracker.java @@ -26,8 +26,15 @@ public interface TabOutScopesTracker { /** * Checks whether given offset is at the end of tracked scope (so if caret is located at that offset, Tab key can be used to move out of * the scope). - * - * @param removeScope if {@code true}, corresponding scope (if any) will be removed after the call */ - boolean hasScopeEndingAt(@NotNull Editor editor, int offset, boolean removeScope); + boolean hasScopeEndingAt(@NotNull Editor editor, int offset); + + /** + * Removes a tracked scope (if any) ending at the given offset. + * + * @return whether there was a scope ending at given offset + * + * @see #hasScopeEndingAt(Editor, int) + */ + boolean removeScopeEndingAt(@NotNull Editor editor, int offset); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BraceOrQuoteOutAction.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BraceOrQuoteOutAction.java index 455853e915ee..8265296fca8f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BraceOrQuoteOutAction.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/BraceOrQuoteOutAction.java @@ -22,14 +22,14 @@ public class BraceOrQuoteOutAction extends EditorAction { @Override protected boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) { int caretOffset = caret.getOffset(); - return TabOutScopesTracker.getInstance().hasScopeEndingAt(editor, caretOffset, false); + return TabOutScopesTracker.getInstance().hasScopeEndingAt(editor, caretOffset); } @Override protected void doExecute(@NotNull Editor editor, @Nullable Caret caret, DataContext dataContext) { assert caret != null; int caretOffset = caret.getOffset(); - if (TabOutScopesTracker.getInstance().hasScopeEndingAt(editor, caretOffset, true)) { + if (TabOutScopesTracker.getInstance().removeScopeEndingAt(editor, caretOffset)) { caret.moveToOffset(caretOffset + 1); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TabOutScopesTrackerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TabOutScopesTrackerImpl.java index 84a986e1c342..e28cd6be895c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TabOutScopesTrackerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/TabOutScopesTrackerImpl.java @@ -22,6 +22,7 @@ import java.util.Iterator; import java.util.List; public class TabOutScopesTrackerImpl implements TabOutScopesTracker { + @Override public void registerEmptyScope(@NotNull Editor editor, int offset) { ApplicationManager.getApplication().assertIsDispatchThread(); assert !editor.isDisposed() : "Disposed editor"; @@ -39,7 +40,17 @@ public class TabOutScopesTrackerImpl implements TabOutScopesTracker { tracker.registerScope(offset); } - public boolean hasScopeEndingAt(@NotNull Editor editor, int offset, boolean removeScope) { + @Override + public boolean hasScopeEndingAt(@NotNull Editor editor, int offset) { + return checkOrRemoveScopeEndingAt(editor, offset, false); + } + + @Override + public boolean removeScopeEndingAt(@NotNull Editor editor, int offset) { + return checkOrRemoveScopeEndingAt(editor, offset, true); + } + + private static boolean checkOrRemoveScopeEndingAt(@NotNull Editor editor, int offset, boolean removeScope) { ApplicationManager.getApplication().assertIsDispatchThread(); if (!CodeInsightSettings.getInstance().TAB_EXITS_BRACKETS_AND_QUOTES) return false;