mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-192970 'Tab out' doesn't work for completed if/while/switch
This commit is contained in:
+3
-15
@@ -1,22 +1,9 @@
|
||||
/*
|
||||
* Copyright 2000-2009 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.
|
||||
*/
|
||||
// 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 com.intellij.codeInsight.completion.simple;
|
||||
|
||||
import com.intellij.codeInsight.TailType;
|
||||
import com.intellij.codeInsight.editorActions.TabOutScopesTracker;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
@@ -50,6 +37,7 @@ public abstract class ParenthesesTailType extends TailType {
|
||||
} else {
|
||||
tailOffset = insertChar(editor, tailOffset, ')');
|
||||
moveCaret(editor, tailOffset, -1);
|
||||
TabOutScopesTracker.getInstance().registerEmptyScopeAtCaret(editor);
|
||||
}
|
||||
return tailOffset;
|
||||
}
|
||||
|
||||
@@ -65,6 +65,14 @@ public class EditorTabOutTest extends AbstractParameterInfoTestCase {
|
||||
checkResult("class C { int[] ar = new int[123]<caret> }");
|
||||
}
|
||||
|
||||
public void testWhile() {
|
||||
configureJava("class C { void m() { whil<caret> } }");
|
||||
complete();
|
||||
type("true");
|
||||
tabOut();
|
||||
checkResult("class C { void m() { while (true)<caret>} }");
|
||||
}
|
||||
|
||||
private void tabOut() {
|
||||
myFixture.performEditorAction(IdeActions.ACTION_BRACE_OR_QUOTE_OUT);
|
||||
}
|
||||
|
||||
+1
-1
@@ -160,7 +160,7 @@ public abstract class ParenthesesInsertHandler<T extends LookupElement> implemen
|
||||
editor.getCaretModel().moveToOffset(context.getTailOffset());
|
||||
}
|
||||
else if (!mySpaceBeforeParentheses) {
|
||||
TabOutScopesTracker.getInstance().registerEmptyScope(editor, editor.getCaretModel().getOffset());
|
||||
TabOutScopesTracker.getInstance().registerEmptyScopeAtCaret(editor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,14 @@ public interface TabOutScopesTracker {
|
||||
return ServiceManager.getService(TabOutScopesTracker.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new scope (empty at the time of call) at caret offset. Caret is supposed to be located between just inserted pair
|
||||
* of quotes/brackets.
|
||||
*/
|
||||
default void registerEmptyScopeAtCaret(@NotNull Editor editor) {
|
||||
registerEmptyScope(editor, editor.getCaretModel().getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a new scope (empty at the time of call) at the given offset. Provided offset is supposed to point at the location between
|
||||
* just inserted pair of quotes/brackets.
|
||||
|
||||
Reference in New Issue
Block a user