Skip to content

Commit

Permalink
feat: docstrings shift
Browse files Browse the repository at this point in the history
WIP
  • Loading branch information
rtetley committed Jan 21, 2025
1 parent 1439af4 commit 5413438
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions language-server/dm/document.ml
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,11 @@ let invalidate top_edit top_id parsed_doc new_sentences =
let invalid_ids, doc = invalidate_diff parsed_doc scheduler_state Stateid.Set.empty diff in
unchanged_id, invalid_ids, doc

let shift_hover_info document ~from ~amount =
let {hover_info} = document in
let hover_info = HoverInfo.shift hover_info ~from ~amount in
{document with hover_info}

(** Validate document when raw text has changed *)
let validate_document ({ parsed_loc; raw_doc; cancel_handle } as document) =
(* Cancel any previous parsing event *)
Expand Down
2 changes: 2 additions & 0 deletions language-server/dm/document.mli
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ val raw_document : document -> RawDocument.t

val outline : document -> outline

val shift_hover_info : document -> from:int -> amount:int -> document

val create_document : Vernacstate.Synterp.t -> string -> document
(** [create_document init_synterp_state text] creates a fresh document with content defined by
[text] under [init_synterp_state]. *)
Expand Down
1 change: 1 addition & 0 deletions language-server/dm/documentManager.ml
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ let apply_text_edits state edits =
let edit_length = edit_stop - edit_start in
let exec_st = ExecutionManager.shift_diagnostics_locs exec_st ~start:edit_stop ~offset:(String.length new_text - edit_length) in
let execution_state = ExecutionManager.shift_overview exec_st ~before:(Document.raw_document state.document) ~after:(Document.raw_document document) ~start:edit_stop ~offset:(String.length new_text - edit_length) in
let document = Document.shift_hover_info document ~from:edit_stop ~amount:(String.length new_text - edit_length) in
{state with execution_state; document}
in
let state = List.fold_left apply_edit_and_shift_diagnostics_locs_and_overview state edits in
Expand Down

0 comments on commit 5413438

Please sign in to comment.