From 91332920446e895b14aee4af0ae1b520980ea5d0 Mon Sep 17 00:00:00 2001 From: Nicolas Berthier Date: Thu, 5 Oct 2023 14:43:11 +0200 Subject: [PATCH] Avoid folding over source lines that only denote the end-of-input/file --- src/lsp/cobol_preproc/preproc.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lsp/cobol_preproc/preproc.ml b/src/lsp/cobol_preproc/preproc.ml index 788de9633..68d6c3851 100644 --- a/src/lsp/cobol_preproc/preproc.ml +++ b/src/lsp/cobol_preproc/preproc.ml @@ -113,7 +113,9 @@ let fold_source_lines pl ~f acc = spit_chunk suffix (acc, new_lnum, []) in let acc, last_lnum, tail = fold_source_chunks pl spit_chunk (acc, 1, []) in - f last_lnum tail acc (* fold on the last line upon exit *) + match tail with (* fold on the last line upon exit... *) + | [] | { payload = Eof; _ } :: _ -> acc (* ... if non-empty *) + | _ -> f last_lnum tail acc (* --- *)