aboutsummaryrefslogtreecommitdiff
path: root/ide
diff options
context:
space:
mode:
authorJim Fehrle2018-08-07 11:59:11 -0700
committerJim Fehrle2018-09-20 13:21:18 -0700
commit2dc65d41b0c3b3481958e1e224fd5ef05f57f243 (patch)
tree76849de729430ee17134fa8993ec7913ec92d321 /ide
parenta828bcedb8ad60c5b1f4cf71f92f24f2c1197ecb (diff)
Current diff code only compares the first current goal of the old and new
proof states. That's not always correct. This change will a) show diffs for all displayed goals and b) correctly match goals between the old and new proof states. For example, "split." will show diffs for both resulting goals. "all: swap 1 2" will show the same diffs as for the old proof state, though in a different position in the output. Please see comments before Proof_diffs.make_goal_map_i and Proof_diffs.match_goals for a description of how goals are matched between old and new proofs.
Diffstat (limited to 'ide')
-rw-r--r--ide/idetop.ml36
1 files changed, 22 insertions, 14 deletions
diff --git a/ide/idetop.ml b/ide/idetop.ml
index d846b3abb5..8a221a93e9 100644
--- a/ide/idetop.ml
+++ b/ide/idetop.ml
@@ -204,27 +204,35 @@ let export_pre_goals pgs =
Interface.given_up_goals = pgs.Proof.given_up_goals
}
-let add_diffs oldp newp intf =
- let open Interface in
- let (hyps_pp_list, concl_pp) = Proof_diffs.diff_first_goal oldp newp in
- match intf.fg_goals with
- | [] -> intf
- | first_goal :: tl ->
- { intf with fg_goals = { first_goal with goal_hyp = hyps_pp_list; goal_ccl = concl_pp } :: tl }
-
let goals () =
let doc = get_doc () in
set_doc @@ Stm.finish ~doc;
try
let newp = Proof_global.give_me_the_proof () in
- let intf = export_pre_goals (Proof.map_structured_proof newp process_goal) in
- if Proof_diffs.show_diffs () then
+ if Proof_diffs.show_diffs () then begin
let oldp = Stm.get_prev_proof ~doc (Stm.get_current_state ~doc) in
+ let diff_goal_map = Proof_diffs.make_goal_map oldp newp in
+ let map_goal_for_diff ng = (* todo: move to proof_diffs.ml *)
+ try Evar.Map.find ng diff_goal_map with Not_found -> ng
+ in
+
+ let process_goal_diffs nsigma ng =
+ let open Evd in
+ let og = map_goal_for_diff ng in
+ let og_s = match oldp with
+ | Some oldp ->
+ let (_,_,_,_,osigma) = Proof.proof oldp in
+ Some { it = og; sigma = osigma }
+ | None -> None
+ in
+ let (hyps_pp_list, concl_pp) = Proof_diffs.diff_goal_ide og_s ng nsigma in
+ { Interface.goal_hyp = hyps_pp_list; Interface.goal_ccl = concl_pp; Interface.goal_id = Goal.uid ng }
+ in
try
- Some (add_diffs oldp (Some newp) intf)
- with Pp_diff.Diff_Failure _ -> Some intf
- else
- Some intf
+ Some (export_pre_goals (Proof.map_structured_proof newp process_goal_diffs))
+ with Pp_diff.Diff_Failure _ -> Some (export_pre_goals (Proof.map_structured_proof newp process_goal))
+ end else
+ Some (export_pre_goals (Proof.map_structured_proof newp process_goal))
with Proof_global.NoCurrentProof -> None;;
let evars () =