Skip to content

Commit 5fb7f1d

Browse files
authored
Merge pull request #149 from phijor/fix-loading-ro-files
Ignore failed writes when loading buffer
2 parents c97b481 + 60fa86a commit 5fb7f1d

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/Plugin.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ load = withAgda $ withCurrentBuffer $ \b -> do
8181
agda <- getAgda b
8282
ready <- liftIO $ readIORef $ a_ready agda
8383
if ready then do
84-
vim_command "noautocmd w"
84+
vim_command "silent! noautocmd w"
8585
name <- buffer_get_name $ a_buffer agda
8686
flip runIOTCM agda $ Cmd_load name []
8787
buffer_get_number b >>= resetDiff

test/Readonly.agda

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module Readonly where
2+
3+
open import Agda.Builtin.String
4+
5+
description : String
6+
description = "This is a read-only file. Loading it should work fine."

test/TestSpec.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Control.Monad (void)
88
import Cornelis.Subscripts (decNextDigitSeq, incNextDigitSeq)
99
import Cornelis.Types
1010
import Cornelis.Types.Agda (Rewrite (..))
11-
import Cornelis.Utils (withBufferStuff)
11+
import Cornelis.Utils (withBufferStuff, withLocalEnv)
1212
import Cornelis.Vim
1313
import qualified Data.Text as T
1414
import qualified Data.Vector as V
@@ -18,6 +18,7 @@ import Neovim.Test
1818
import Plugin
1919
import Test.Hspec
2020
import Utils
21+
import Lib (cornelisInit)
2122

2223

2324
broken :: String -> SpecWith a -> SpecWith a
@@ -26,6 +27,15 @@ broken = before_ . pendingWith
2627
spec :: Spec
2728
spec = focus $ do
2829
let timeout = Seconds 60
30+
31+
it "should load read-only file" $ do
32+
withVim timeout $ \w b -> do
33+
env <- cornelisInit
34+
withLocalEnv env $ do
35+
vim_command "view test/Readonly.agda"
36+
liftIO $ threadDelay 1e6
37+
load
38+
2939
diffSpec "should refine" timeout "test/Hello.agda"
3040
[ Swap "unit = ?" "unit = one"] $ \w _ -> do
3141
goto w 11 8

0 commit comments

Comments
 (0)