-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add :next and :previous commands for vim keymap #1075
base: master
Are you sure you want to change the base?
Conversation
…nd :bnext, etc for now)
…rs are actually added to list)
I'm not sure if we want to emulate vim's behavior exactly, but |
I suspect what I've ended up doing here is neither. |
parse :: EventString -> Maybe ExCommand | ||
parse = Common.parse $ do | ||
void (P.char 'b') <|> return () | ||
direction <- (fmap (const False) $ P.string "prev" <|> P.string "previous") <|> fmap (const True) (P.string "next") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P.string "prev" <|> P.string "previous"
is redundant, because the "prev" parser also matches "previous". Maybe this behavior should be changed, because now "prevsomething" is also accepted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be solved by using the endOfInput
parser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened #1085 to track this issue for all parsers.
cl' = if direction | ||
then last cl : init cl | ||
else tail cl ++ [head cl] | ||
in forceSpine cl' `seq` window { bufkey = head cl', bufAccessList = tail cl' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain how this would cause a memory leak without forceSpine
? Isn't the entire list stored in memory anyway?
Edit: I think I see it, the reference to the old cl
is kept.
Edit 2: Are you sure this works? I tried this:
main = do
print $ iterate f [1..100] !! 1000000
where
f x = forceSpine r `seq` r
where
r = tail x ++ [head x]
forceSpine = go
where
go [] = ()
go (_:xs) = go xs
And that still has the leak.
Edit 3: Even this still has the leak:
import Data.List
main = do
print $ foldl' (\xs _ -> f xs) [1..100] (replicate 1000000 ())
where
f x = forceSpine r `seq` r
where
r = tail x ++ [head x]
forceSpine = go
where
go [] = ()
go (_:xs) = go xs
Edit 4: This fixes it:
main = do
print $ iterate f [1..100] !! 1000000
where
f x = forceSpine r `seq` r
where
r = tail x ++ [head x]
forceSpine = go
where
go [] = ()
go (x:xs) = x `seq` go xs
No description provided.