mirror of
https://github.com/chrisdone/duet.git
synced 2025-01-08 06:53:22 +03:00
Fix navigation issue after focusing
This commit is contained in:
parent
a9ccbdfdf9
commit
01b931d84e
@ -63,11 +63,13 @@ interpretKeyDown shift k = do
|
||||
LeftKey ->
|
||||
navigate
|
||||
s
|
||||
(reverse . takeWhile ((/= cursorUUID (stateCursor s)) . labelUUID))
|
||||
(reverse .
|
||||
takeWhile ((/= cursorUUID (stateCursor s)) . labelUUID . nodeLabel))
|
||||
RightKey ->
|
||||
navigate
|
||||
s
|
||||
(dropWhile ((== me) . labelUUID) . dropWhile ((/= me) . labelUUID))
|
||||
(dropWhile ((== me) . labelUUID . nodeLabel) .
|
||||
dropWhile ((/= me) . labelUUID . nodeLabel))
|
||||
where me = cursorUUID (stateCursor s)
|
||||
ReturnKey -> interpretReturn cursor (cursorUUID cursor) (stateAST s)
|
||||
_ -> pure ()
|
||||
@ -76,7 +78,12 @@ interpretKeyDown shift k = do
|
||||
maybe
|
||||
(return ())
|
||||
focusNode
|
||||
(listToMaybe (skip (orderedNodes isAtomicNode (stateAST s))))
|
||||
(listToMaybe
|
||||
(map
|
||||
nodeLabel
|
||||
(filter
|
||||
isAtomicNode
|
||||
(skip (orderedNodes (stateAST s))))))
|
||||
|
||||
isAtomicNode :: Node -> Bool
|
||||
isAtomicNode =
|
||||
@ -647,20 +654,18 @@ interpretSpaceCompletion cursor ast = do
|
||||
--------------------------------------------------------------------------------
|
||||
-- Interpreter utilities
|
||||
|
||||
orderedNodes :: (Node -> Bool) -> Node -> [Label]
|
||||
orderedNodes ok =
|
||||
orderedNodes :: Node -> [Node]
|
||||
orderedNodes =
|
||||
everything
|
||||
(++)
|
||||
(extQ
|
||||
(extQ
|
||||
(mkQ
|
||||
[]
|
||||
(\(ImplicitlyTypedBinding _ bind@(_, l2) _ :: ImplicitlyTypedBinding Ignore Identifier Label) ->
|
||||
[l2 | ok (NameNode bind)]))
|
||||
(\(e :: Expression Ignore Identifier Label) ->
|
||||
[expressionLabel e | ok (ExpressionNode e)]))
|
||||
(\(p :: Pattern Ignore Identifier Label) ->
|
||||
[patternLabel p | ok (PatternNode p)]))
|
||||
(\(ImplicitlyTypedBinding _ bind@(_, _) _ :: ImplicitlyTypedBinding Ignore Identifier Label) ->
|
||||
[NameNode bind]))
|
||||
(\(e :: Expression Ignore Identifier Label) -> [ExpressionNode e]))
|
||||
(\(p :: Pattern Ignore Identifier Label) -> [PatternNode p]))
|
||||
|
||||
nodeHoles :: UUID -> Node -> [Label]
|
||||
nodeHoles base =
|
||||
|
@ -728,6 +728,40 @@ infixTests =
|
||||
(VariableExpression
|
||||
(Label {labelUUID = UUID "1"})
|
||||
(Identifier {identifierString = "x"})))))
|
||||
, Test
|
||||
"Moving after focusing a parent works like normal"
|
||||
[ KeyPressAction 'x'
|
||||
, KeyPressAction '+'
|
||||
, KeyPressAction '2'
|
||||
, KeyPressAction '*'
|
||||
, KeyPressAction '3'
|
||||
, KeyPressAction ')'
|
||||
, KeyDownAction False LeftKey
|
||||
]
|
||||
(focus
|
||||
(UUID "3")
|
||||
(rhsSelectedState
|
||||
(InfixExpression
|
||||
(Label {labelUUID = UUID "2"})
|
||||
(VariableExpression
|
||||
(Label {labelUUID = UUID "STARTER-EXPR"})
|
||||
(Identifier {identifierString = "x"}))
|
||||
( "+"
|
||||
, VariableExpression
|
||||
(Label {labelUUID = UUID "3"})
|
||||
(Identifier {identifierString = "+"}))
|
||||
(InfixExpression
|
||||
(Label {labelUUID = UUID "5"})
|
||||
(LiteralExpression
|
||||
(Label {labelUUID = UUID "1"})
|
||||
(IntegerLiteral 2))
|
||||
( "*"
|
||||
, VariableExpression
|
||||
(Label {labelUUID = UUID "6"})
|
||||
(Identifier {identifierString = "*"}))
|
||||
(LiteralExpression
|
||||
(Label {labelUUID = UUID "4"})
|
||||
(IntegerLiteral 3))))))
|
||||
]
|
||||
|
||||
variableTests :: [Test]
|
||||
|
Loading…
Reference in New Issue
Block a user