Skip to content

Commit

Permalink
Merge pull request yi-editor#43 from ethercrow/filename_completion
Browse files Browse the repository at this point in the history
Sanitize filename expanded from '%' in ex mode
  • Loading branch information
ethercrow committed Sep 16, 2012
2 parents 1846f05 + cbdb9a6 commit 1a52ed8
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions yi/src/library/Yi/Keymap/Vim.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1261,16 +1261,18 @@ exMode self prompt = do
-- current buffer is minibuffer
-- actual file is in the second buffer in bufferStack
bufferRef <- withEditor $ gets (head . drop 1 . bufferStack)
maybeCurrentFileName <- withGivenBuffer bufferRef (gets file)

case maybeCurrentFileName of
Just fn -> withBuffer $ do
-- now modifying minibuffer
point <- pointB
deleteNAt Forward 1 (point-1)
insertN fn

Nothing -> return ()
currentFileName <- withGivenBuffer bufferRef $
fmap bufInfoFileName bufInfoB

let sanitizedFileName = case currentFileName of
('/':'/':f) -> '/':f
otherwise -> currentFileName

-- now modifying minibuffer
withBuffer $ do
point <- pointB
deleteNAt Forward 1 (point-1)
insertN sanitizedFileName
| otherwise = exFileNameComplete f

b_complete = exSimpleComplete matchingBufferNames
Expand Down

0 comments on commit 1a52ed8

Please sign in to comment.