Hi!
I've started playing around with Yi and I'm truly impressed!
The code is beautiful and hackable, keep up the great work!

There is a little issue with word and WORD motions  -- they work
differently to Vim at the end of lines.

Here is what I learned after looking at Vim's source code (src/search.c,
fwd_word() and friends):
Newlines are just normal whitespace, but empty lines (\n\n) are dealt
with specially --
all w, W, b, B, e, E motions stop at them. Despite of this (and some
magic for kana) Yi seems to do the same stuff Vim does.

I'm just starting to learn Haskell, so please forgive me if code in
patch is ugly or broken.

Cheers,
-- 
Krzysiek

--~--~---------~--~----~------------~-------~--~----~
Yi development mailing list
[email protected]
http://groups.google.com/group/yi-devel
-~----------~----~----~----~------~----~------~--~---

diff -rN old-yi/Yi/Buffer/Normal.hs new-yi/Yi/Buffer/Normal.hs
61a62,63
> 
> unitWord, unitViWord, unitViWORD :: TextUnit
64a67,68
> 
> unitDelimited :: Char -> Char -> Bool -> TextUnit
73,77d76
< -- | A visible space is one that actually takes up space on screen. In other 
< -- words: everything but the newline. 
< isVisSpace :: Char -> Bool
< isVisSpace c = (not $ isNl c) && (isSpace c)
< 
101a101,108
> atViWordBoundary :: (Char -> Int) -> Direction -> BufferM Bool
> atViWordBoundary charType direction = do
>     cs <- peekB direction 2 (-1)
>     return $ case cs of
>       [nl1,nl2] | isNl nl1 && isNl nl2 -> True -- stop at empty lines
>       [c1,c2] -> not (isSpace c1) && (charType c1 /= charType c2)
>       _ -> True
> 
110,119c117,123
< atBoundary ViWORD direction =
<     checkPeekB (-1) [not . isVisSpace, isVisSpace] direction
< atBoundary ViWord direction = do
<     cs <- peekB direction 2 (-1)
<     return $ case cs of
<       [c1,c2] -> not (isVisSpace c1) && (charType c1 /= charType c2)
<         where charType c | isVisSpace c = 1::Int
<                          | isWordChar c = 2
<                          | otherwise    = 3
<       _ -> True
---
> atBoundary ViWORD direction = atViWordBoundary charType direction
>     where charType c | isSpace c = 1::Int
>                      | otherwise = 2
> atBoundary ViWord direction = atViWordBoundary charType direction
>     where charType c | isSpace c    = 1::Int
>                      | isWordChar c = 2
>                      | otherwise    = 3

Reply via email to