Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some cleanup

  • Loading branch information...
commit 1118ee41b25d38e0a6cdab14b0b1e6e274c09f4d 1 parent 0afdd78
Michael Feathers authored
Showing with 7 additions and 6 deletions.
  1. +6 −6 editbuffer.hs
  2. +1 −0  todo
12 editbuffer.hs
View
@@ -50,8 +50,8 @@ deleteChar buffer@(EditBuffer topLine location@(x,y) contents)
replaceChar :: Char -> EditBuffer -> EditBuffer
replaceChar replacementChar buffer@(EditBuffer topLine location contents) =
- let newContents = [transform x | x <- numberedElements contents]
- transform (ch, pos) = if pos == (absPosition buffer) then replacementChar else ch
+ let newContents = map f . numberedElements $ contents
+ f (ch, pos) = if pos == (absPosition buffer) then replacementChar else ch
in EditBuffer topLine location newContents
@@ -133,9 +133,9 @@ absPosition (EditBuffer _ (x, y) contents) =
locationFromPosition :: Int -> String -> Location
locationFromPosition pos contents =
- let foreText = init . lines . take (pos + 1) $ contents
- x = pos - (length $ unlines foreText)
- y = length foreText
+ let foreLines = init . lines . take (pos + 1) $ contents
+ x = pos - (length $ unlines foreLines)
+ y = length foreLines
in (x, y)
isPunct :: Char -> Bool
@@ -143,7 +143,7 @@ isPunct ch = isAscii ch && not (isAlphaNum ch) && not (isSpace ch) && not (isCon
dropWord :: [(Char,a)] -> [(Char,a)]
dropWord [] = []
-dropWord all@((ch,_):xs)
+dropWord all@((ch,_):_)
| isPunct ch = dropPuncts all
| isAlphaNum ch = dropAlphaNums all
| otherwise = all
1  todo
View
@@ -4,6 +4,7 @@
- Put test driver in place
- Documentation
- Investigate state State T IO monad for mainLoop
+- bug in wordBackward. Never gets to first word in buffer if flush
x Simplify locationFromPosition. May not need cumulative sum
x Add punct groups as words in wordForward
x Add wordBackward
Please sign in to comment.
Something went wrong with that request. Please try again.