Skip to content

Commit 03a4bf2

Browse files
committed
Fixing highlights when there is a non invalidating edit WIP
1 parent 6bfac58 commit 03a4bf2

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

language-server/dm/documentManager.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,14 @@ let reset { uri; opts; init_vs; document; execution_state; observe_id } =
311311

312312
let apply_text_edits state edits =
313313
let document = Document.apply_text_edits state.document edits in
314-
let shift_diagnostics_locs exec_st (range, new_text) =
314+
let shift_diagnostics_locs_and_overview exec_st (range, new_text) =
315315
let edit_start = RawDocument.loc_of_position (Document.raw_document state.document) range.Range.start in
316316
let edit_stop = RawDocument.loc_of_position (Document.raw_document state.document) range.Range.end_ in
317317
let edit_length = edit_stop - edit_start in
318-
ExecutionManager.shift_diagnostics_locs exec_st ~start:edit_stop ~offset:(String.length new_text - edit_length)
318+
let exec_st = ExecutionManager.shift_diagnostics_locs exec_st ~start:edit_stop ~offset:(String.length new_text - edit_length) in
319+
ExecutionManager.shift_overview exec_st (Document.raw_document state.document) ~start:edit_stop ~offset:(String.length new_text - edit_length)
319320
in
320-
let execution_state = List.fold_left shift_diagnostics_locs state.execution_state edits in
321+
let execution_state = List.fold_left shift_diagnostics_locs_and_overview state.execution_state edits in
321322
validate_document { state with document; execution_state }
322323

323324
let handle_event ev st =

language-server/dm/executionManager.ml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -744,17 +744,15 @@ let all_feedback st =
744744
List.fold_left (fun acc (id, (_,l)) -> List.map (fun x -> (id, x)) l @ acc) [] @@ SM.bindings st.of_sentence
745745

746746
let shift_overview st raw_doc ~start ~offset =
747-
let shift_loc loc =
748-
let (loc_start, loc_stop) = Loc.unloc loc in
749-
if loc_start >= start then Loc.shift_loc offset offset loc
750-
else if loc_stop > start then Loc.shift_loc 0 offset loc
751-
else loc
747+
let shift_loc loc_start loc_end =
748+
if loc_start >= start then (loc_start + offset, loc_end + offset)
749+
else if loc_end > start then (loc_start, loc_end + offset)
750+
else (loc_start, loc_end)
752751
in
753752
let shift_range range =
754753
let r_start = RawDocument.loc_of_position raw_doc range.Range.start in
755754
let r_stop = RawDocument.loc_of_position raw_doc range.Range.end_ in
756-
let r_start' = shift_loc r_start in
757-
let r_stop' = shift_loc r_stop in
755+
let r_start', r_stop' = shift_loc r_start r_stop in
758756
Range.create ~start:(RawDocument.position_of_loc raw_doc r_start') ~end_:(RawDocument.position_of_loc raw_doc r_stop')
759757
in
760758
let processed = CList.Smart.map shift_range st.overview.processed in

language-server/dm/executionManager.mli

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ val feedback : state -> sentence_id -> feedback_message list
5454
val all_errors : state -> (sentence_id * (Loc.t option * Pp.t)) list
5555
val all_feedback : state -> (sentence_id * feedback_message) list
5656

57+
val shift_overview : state -> RawDocument.t -> start:int -> offset:int -> state
5758
val shift_diagnostics_locs : state -> start:int -> offset:int -> state
5859
val executed_ids : state -> sentence_id list
5960
val is_executed : state -> sentence_id -> bool

0 commit comments

Comments
 (0)