diff --git a/TODO.txt b/TODO.txt index 6007b684..41e12229 100644 --- a/TODO.txt +++ b/TODO.txt @@ -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 ;__; diff --git a/src/Potato/Data/Text/Zipper.hs b/src/Potato/Data/Text/Zipper.hs index ec7b92f6..6e74e4da 100644 --- a/src/Potato/Data/Text/Zipper.hs +++ b/src/Potato/Data/Text/Zipper.hs @@ -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 diff --git a/test/Potato/Data/Text/ZipperSpec.hs b/test/Potato/Data/Text/ZipperSpec.hs index 26ad6c07..2b39a631 100644 --- a/test/Potato/Data/Text/ZipperSpec.hs +++ b/test/Potato/Data/Text/ZipperSpec.hs @@ -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