File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -133,10 +133,24 @@ let version (t : t) = t.document.version
133133
134134let languageId (t : t ) = t.document.languageId
135135
136+ let debug =
137+ match Sys. getenv_opt " OCAMLLSP_DEBUG_CHANGES" with
138+ | None -> None
139+ | Some f -> Some (open_out f)
140+
141+ let () =
142+ at_exit (fun () ->
143+ match debug with
144+ | None -> ()
145+ | Some f -> close_out f)
146+
136147let apply_change encoding text (change : TextDocumentContentChangeEvent.t ) =
137148 match change.range with
138149 | None -> change.text
139150 | Some range ->
151+ (match debug with
152+ | None -> ()
153+ | Some out -> Printf. fprintf out " %s\n ---\n " text);
140154 let start_offset, end_offset =
141155 let utf8 = text in
142156 match encoding with
@@ -153,12 +167,28 @@ let apply_change encoding text (change : TextDocumentContentChangeEvent.t) =
153167 |> Array_view. make ~pos: 0 |> Substring. concat
154168
155169let apply_content_changes ?version t changes =
170+ (match debug with
171+ | None -> ()
172+ | Some out ->
173+ Printf. fprintf
174+ out
175+ " changes:\n %s\n ---\n %s\n ---\n "
176+ (Yojson.Safe. pretty_to_string
177+ ~std: false
178+ (`List
179+ (List. map changes ~f: TextDocumentContentChangeEvent. yojson_of_t)))
180+ t.document.text);
156181 let text =
157182 List. fold_left
158183 ~f: (apply_change t.position_encoding)
159184 ~init: t.document.text
160185 changes
161186 in
187+ (match debug with
188+ | None -> ()
189+ | Some out ->
190+ Printf. fprintf out " %s\n ---\n " text;
191+ flush out);
162192 let document = { t.document with text } in
163193 let document =
164194 match version with
You can’t perform that action at this time.
0 commit comments