Skip to content

Commit

Permalink
Fix the gap calculation algorithm to be more efficient.
Browse files Browse the repository at this point in the history
We no only calculate the single line gap in the case of SingleLine
style useage. The previous code had some errors in the case statement.
This version makes more sense and seems more readable to me.
  • Loading branch information
jwall@google.com committed Oct 12, 2010
1 parent 6bc1138 commit bca1ead
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Yi/Buffer/HighLevel.hs
Expand Up @@ -18,7 +18,7 @@ import Yi.Buffer.Normal
import Yi.Buffer.Region
import Yi.String
import Yi.Window
import Yi.Config.Misc (ScrollStyle)
import Yi.Config.Misc (ScrollStyle(SingleLine))

-- ---------------------------------------------------------------------
-- Movement operations
Expand Down Expand Up @@ -401,12 +401,12 @@ snapScreenB style = do
h <- askWindow actualLines
r <- winRegionB
p <- pointB
let gap = case pointScreenRelPosition p (regionStart r) (regionEnd r) of
Above -> 0
Below -> case style of
Nothing -> h `div` 2
_ -> h - 1
Within -> 0 -- Impossible but handle it anyway
let gap = case style of
Just SingleLine -> case pointScreenRelPosition p (regionStart r) (regionEnd r) of
Above -> 0
Below -> h - 1
Within -> 0 -- Impossible but handle it anyway
_ -> h `div` 2
i <- indexOfSolAbove gap
f <- fromMark <$> askMarks
setMarkPointB f i
Expand Down

0 comments on commit bca1ead

Please sign in to comment.