mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[editor] IDEA-273139 Smart enter should work for host language in single-line injections
GitOrigin-RevId: b7b1c6992b1afa545b96d79bf75ed8a4ea5f3469
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3838d60ce2
commit
21c160097d
@@ -0,0 +1,5 @@
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class InInjection {
|
||||
static final Pattern p = Pattern.compile("\\d+<caret>")
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class InInjection {
|
||||
static final Pattern p = Pattern.compile("\\d+");
|
||||
}
|
||||
@@ -191,6 +191,7 @@ public class CompleteStatementTest extends EditorActionTestCase {
|
||||
public void testOverloadedMethodOneOrThree2() { doTest(); }
|
||||
public void testOverloadedMethodOneOrThree3() { doTest(); }
|
||||
public void testMissingComma() { doTest(); }
|
||||
public void testInInjection() { doTest(); }
|
||||
|
||||
private void doTestBracesNextLineStyle() {
|
||||
myJavaSettings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
|
||||
+5
@@ -6,6 +6,7 @@ import com.intellij.codeInsight.editorActions.enter.EnterAfterUnmatchedBraceHand
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import com.intellij.injected.editor.EditorWindow;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
@@ -32,6 +33,10 @@ public class SmartEnterAction extends EditorAction {
|
||||
private static class Handler extends EditorWriteActionHandler.ForEachCaret {
|
||||
@Override
|
||||
public boolean isEnabledForCaret(@NotNull Editor editor, @NotNull Caret caret, DataContext dataContext) {
|
||||
if (editor.isOneLineMode() && editor instanceof EditorWindow) {
|
||||
// One-line injection: prefer for host instead
|
||||
return false;
|
||||
}
|
||||
return getEnterHandler().isEnabled(editor, caret, dataContext);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user