-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Incorrect auto-insertion of
}
on Enter #216
- Loading branch information
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/main/java/intellij_awk/AwkEnterAfterUnmatchedBraceHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package intellij_awk; | ||
|
||
import com.intellij.codeInsight.editorActions.enter.EnterAfterUnmatchedBraceHandler; | ||
import com.intellij.openapi.util.Pair; | ||
import com.intellij.psi.*; | ||
import com.intellij.util.text.CharArrayUtil; | ||
import intellij_awk.psi.AwkFile; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class AwkEnterAfterUnmatchedBraceHandler extends EnterAfterUnmatchedBraceHandler { | ||
@Override | ||
public boolean isApplicable(@NotNull PsiFile file, int caretOffset) { | ||
return file instanceof AwkFile; | ||
} | ||
|
||
@Override | ||
protected Pair<PsiElement, Integer> calculateOffsetToInsertClosingBrace( | ||
@NotNull PsiFile file, @NotNull CharSequence text, int offset) { | ||
return Pair.create(null, CharArrayUtil.shiftForwardUntil(text, offset, "\n")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters