Skip to content
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

[server] Warn the user of possible problems when >= 2 files are open. #169

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coq-lsp 0.1.3:
------------------------
# coq-lsp 0.1.3: View
---------------------

- Much improved handling of Coq fatal errors, the server is now
hardened against them (@ejgallego, #155, #157, #160, fixes #91)
Expand All @@ -9,6 +9,9 @@
to a command; this makes VsCodeVim cursor tracking work; thanks to
Cactus (Anton) Golov for detailed bug reporting and testing
(@ejgallego, @jesyspa, #170, fixes #163)
- `coq-lsp` will now warn the user when two files have been opened
simultaneously and the parser may go into a broken state :/
(@ejgallego #169)

# coq-lsp 0.1.2: Message
------------------------
Expand Down
16 changes: 16 additions & 0 deletions controller/doc_manager.ml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ let create ~root_state ~workspace ~uri ~contents ~version =
LIO.trace "Fleche.Doc.create" ("internal error" ^ msg)
| Coq.Protect.R.Interrupted -> ()

(* Can't wait for the day this goes away *)
let tainted = ref false

let create ~root_state ~workspace ~uri ~contents ~version =
if !tainted then
(* Warn about Coq bug *)
let message =
"You have opened two or more Coq files simultaneously in the server\n\
Unfortunately Coq's parser doesn't properly support that setup yet\n\
If you see some strange parsing errors please close all files but one\n\
Then restart the coq-lsp server; sorry for the inconveniencies"
in
LIO.logMessage ~lvl:2 ~message
else tainted := true;
create ~root_state ~workspace ~uri ~contents ~version

let change ~uri ~version ~contents =
let doc = Handle.find_doc ~uri in
if version > doc.version then (
Expand Down