banacorn / agda-mode

agda-mode on Atom
https://atom.io/packages/agda-mode
MIT License
58 stars 14 forks source link

Interaction holes appearing in wrong place #58

Closed DrNico closed 6 years ago

DrNico commented 6 years ago

Here's an interesting bug. Commented lines ending with a dash cause subsequent interaction holes to appear in the wrong place, thereby causing mayhem with the file contents.

Example source code causing the problem:

data Nat : Set where
    zero    : Nat
    succ    : Nat → Nat

{- line ending with dash -
-}

plus : Nat → Nat → Nat
plus zero n     = ?
plus (succ m) n = plus m (succ n)

Then load (^c - ^l) and watch the hole overwriting and pushing text around.

Setup is:

banacorn commented 6 years ago

Issue reproduced!

I believe this has something to do with "hole finding": https://github.com/banacorn/agda-mode/blob/master/src/parser/hole.ts

The parsing is now done with some awful regular expressions, an ugly patch should fix it.

Hope that the parsing can be done in CFG in the future (with tree-sitter), or perhaps we can do away with parsing completely by having a better interface with agda.