Fix navigation issue after focusing

This commit is contained in:
Chris Done 2017-12-11 11:45:48 +00:00
parent a9ccbdfdf9
commit 01b931d84e
2 changed files with 50 additions and 11 deletions

View File

@ -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 =

View File

@ -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]