Skip to content

Commit c15795c

Browse files
committed
refactor: handle structural tabbing for the breaking change symbol
1 parent 4e5ae66 commit c15795c

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/main/kotlin/com/github/lppedd/cc/editor/CommitTabAction.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ internal class CommitTabAction : TabAction() {
5656
val elementAtCaret = psiFile?.findElementAt(editor.getCaretOffset())
5757

5858
if (elementAtCaret is ConventionalCommitScopeOpenParenPsiElement ||
59-
elementAtCaret is ConventionalCommitScopeCloseParenPsiElement) {
59+
elementAtCaret is ConventionalCommitScopeCloseParenPsiElement ||
60+
elementAtCaret is ConventionalCommitBreakingChangePsiElement) {
6061
editor.putUserData(moveCaretKey, 1)
6162
return true
6263
} else if (elementAtCaret is ConventionalCommitSeparatorPsiElement) {

src/main/kotlin/com/github/lppedd/cc/language/parser/ConventionalCommitASTFactory.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.lppedd.cc.language.parser
22

33
import com.github.lppedd.cc.language.lexer.ConventionalCommitTokenType.Companion.BODY
4+
import com.github.lppedd.cc.language.lexer.ConventionalCommitTokenType.Companion.BREAKING_CHANGE
45
import com.github.lppedd.cc.language.lexer.ConventionalCommitTokenType.Companion.FOOTER_TYPE
56
import com.github.lppedd.cc.language.lexer.ConventionalCommitTokenType.Companion.FOOTER_TYPE_BREAKING_CHANGE
67
import com.github.lppedd.cc.language.lexer.ConventionalCommitTokenType.Companion.FOOTER_VALUE
@@ -27,6 +28,7 @@ internal class ConventionalCommitASTFactory : ASTFactory() {
2728
tokensMap[SCOPE_OPEN_PAREN] = ::ConventionalCommitScopeOpenParenPsiElement
2829
tokensMap[SCOPE] = ::ConventionalCommitScopeValuePsiElement
2930
tokensMap[SCOPE_CLOSE_PAREN] = ::ConventionalCommitScopeCloseParenPsiElement
31+
tokensMap[BREAKING_CHANGE] = ::ConventionalCommitBreakingChangePsiElement
3032
tokensMap[SEPARATOR] = ::ConventionalCommitSeparatorPsiElement
3133
tokensMap[SUBJECT] = ::ConventionalCommitSubjectPsiElement
3234
tokensMap[BODY] = ::ConventionalCommitBodyPsiElement
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.github.lppedd.cc.language.psi
2+
3+
import com.intellij.psi.impl.source.tree.LeafPsiElement
4+
import com.intellij.psi.tree.IElementType
5+
6+
/**
7+
* @author Edoardo Luppi
8+
*/
9+
class ConventionalCommitBreakingChangePsiElement(
10+
type: IElementType,
11+
text: CharSequence,
12+
) : LeafPsiElement(type, text) {
13+
override fun toString(): String =
14+
"ConventionalCommitBreakingChangePsiElement"
15+
}

0 commit comments

Comments
 (0)