Skip to content

Commit

Permalink
extend selection for fields declaration block (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkurnikov authored Jan 16, 2025
1 parent 18cc79d commit 9fa89b7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElement
import org.move.lang.core.LIST_CLOSE_SYMBOLS
import org.move.lang.core.LIST_OPEN_SYMBOLS
import org.move.lang.core.psi.MvBlockFields
import org.move.lang.core.psi.MvFunctionParameterList
import org.move.lang.core.psi.MvTupleFields
import org.move.lang.core.psi.MvTypeArgumentList
import org.move.lang.core.psi.MvTypeParameterList
import org.move.lang.core.psi.MvValueArgumentList
Expand All @@ -15,6 +17,7 @@ class MvListSelectionHandler : ExtendWordSelectionHandlerBase() {
override fun canSelect(e: PsiElement): Boolean =
e is MvFunctionParameterList || e is MvValueArgumentList
|| e is MvTypeParameterList || e is MvTypeArgumentList
|| e is MvBlockFields || e is MvTupleFields

override fun select(
e: PsiElement,
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/move/lang/core/MvTokenType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ val MOVE_BINARY_OPS = tokenSetOf(
AND_EQ, OR_EQ, XOR_EQ, GT_GT_EQ, LT_LT_EQ,
)

val LIST_OPEN_SYMBOLS = tokenSetOf(L_PAREN, LT)
val LIST_CLOSE_SYMBOLS = tokenSetOf(R_PAREN, GT)
val LIST_OPEN_SYMBOLS = tokenSetOf(L_PAREN, LT, L_BRACE)
val LIST_CLOSE_SYMBOLS = tokenSetOf(R_PAREN, GT, R_BRACE)
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,27 @@ class MvListSelectionHandlerTest : MvSelectionHandlerTestBase() {
fun main(): Result<selection><u32, bo<caret>ol></selection> {}
}
""")

fun `test struct field list`() = doTest("""
module 0x1::m {
struct Ss has key { def_val: u8, rut_de<caret>f_val: u16 }
}
""", """
module 0x1::m {
struct Ss has key { def_val: u8, <selection>rut_de<caret>f_val</selection>: u16 }
}
""", """
module 0x1::m {
struct Ss has key { def_val: u8, <selection>rut_de<caret>f_val: u16</selection> }
}
""", """
module 0x1::m {
struct Ss has key {<selection> def_val: u8, rut_de<caret>f_val: u16 </selection>}
}
""", """
module 0x1::m {
struct Ss has key <selection>{ def_val: u8, rut_de<caret>f_val: u16 }</selection>
}
"""
)
}

0 comments on commit 9fa89b7

Please sign in to comment.