Skip to content

Commit

Permalink
feat: the cursor is placed at the end of the error when block on erro…
Browse files Browse the repository at this point in the history
…r is active

Until now, the cursor remained at the last correctly executed sentence.
  • Loading branch information
rtetley committed Dec 11, 2024
1 parent 3f4be24 commit 65084c3
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions language-server/dm/documentManager.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 65084c3

Please sign in to comment.