From 65084c3e0ad04f6ba1b2997310d226070da9b6b9 Mon Sep 17 00:00:00 2001 From: Romain Tetley Date: Wed, 11 Dec 2024 11:32:55 +0100 Subject: [PATCH] feat: the cursor is placed at the end of the error when block on error is active Until now, the cursor remained at the last correctly executed sentence. --- language-server/dm/documentManager.ml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/language-server/dm/documentManager.ml b/language-server/dm/documentManager.ml index bf777dbce..a3b42714f 100644 --- a/language-server/dm/documentManager.ml +++ b/language-server/dm/documentManager.ml @@ -285,17 +285,14 @@ let state_before_error state error_id = match Document.get_sentence state.document error_id with | None -> state, None | Some { start } -> + let error_range = Document.range_of_id_with_blank_space state.document error_id in match Document.find_sentence_before state.document start with | None -> - let start = Position.{line=0; character=0} in - let end_ = Position.{line=0; character=0} in - let last_range = Range.{start; end_} in let observe_id = Top in - {state with observe_id}, Some last_range + {state with observe_id}, Some error_range | Some { id } -> - let last_range = Document.range_of_id_with_blank_space state.document id in let observe_id = (Id id) in - {state with observe_id}, Some last_range + {state with observe_id}, Some error_range let observe ~background state id ~should_block_on_error : (state * event Sel.Event.t list) = match Document.get_sentence state.document id with @@ -313,8 +310,8 @@ let observe ~background state id ~should_block_on_error : (state * event Sel.Eve | None -> {state with execution_state}, [] | Some error_id -> - let state, last_range = state_before_error state error_id in - let events = mk_block_on_error_event last_range error_id in + let state, error_range = state_before_error state error_id in + let events = mk_block_on_error_event error_range error_id in {state with execution_state}, events let reset_to_top st = { st with observe_id = Top } @@ -533,8 +530,9 @@ let execute st id vst_for_next_todo started task background block = let st, block_events = match exec_error with | None -> st, [] - | Some error_id -> let st, last_range = state_before_error st error_id in - let events = if block then mk_block_on_error_event last_range error_id else [] in + | Some error_id -> + let st, error_range = state_before_error st error_id in + let events = if block then mk_block_on_error_event error_range error_id else [] in st, events in let event = Option.map (fun task -> create_execution_event background (Execute {id; vst_for_next_todo; task; started })) next in