Skip to content

Commit

Permalink
fix a minor issu ein Tz and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
minimapletinytools committed Dec 8, 2023
1 parent 4439a07 commit 11f97bb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ DONE-handlers should return preview action
-get it working on breew
-make a video
-update tutorial file?
-empty text zipper should return '' span with cursor
DONE-empty text zipper should return '' span with cursor
-without this, empty cells don't show the cursor...
-NO this is not the issue :()
-shift select in layers please ;__;
Expand Down
2 changes: 1 addition & 1 deletion src/Potato/Data/Text/Zipper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ displayLinesWithAlignment alignment width tag cursorTag (TextZipper lb b a la) =
else (nextacc, [Span tag t])
((_, ecpos_out), curlinespans) = if T.null curlinetext
-- manually handle empty case because mapaccumlfn doesn't handle it
then ((0, Right (0, alignmentOffset alignment width "")), [[Span tag ""]])
then ((0, Right (0, alignmentOffset alignment width "")), [[Span cursorTag ""]])
else L.mapAccumL mapaccumlfn (0, Left 0) curwrappedlines

(cursorY', cursorX) = case ecpos_out of
Expand Down
8 changes: 7 additions & 1 deletion test/Potato/Data/Text/ZipperSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ spec =
_displayLines_spans dl2 `shouldBe` makespans [[""],[""],[""],["aoeu", ""]]
_displayLines_spans dl3 `shouldBe` makespans [["aoeu"],[""],[""],[""]]
_displayLines_spans dl4 `shouldBe` makespans [[""]]


it "displayLinesWithAlignment - cursor tag" $ do
let
dl0 = displayLinesWithAlignment TextAlignment_Right 10 0 1 (fromText "abc")
dl1 = displayLinesWithAlignment TextAlignment_Right 10 0 1 empty
_displayLines_spans dl0 `shouldBe` [[Span 0 "abc", Span 1 ""]]
_displayLines_spans dl1 `shouldBe` [[Span 1 ""]]


it "displayLines - cursorPos" $ do
Expand Down

0 comments on commit 11f97bb

Please sign in to comment.