aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-09-16 13:05:20 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-09-16 13:05:20 +0200
commitbc859a06a13b24daea12d35df2a1ec5114b42180 (patch)
treeaf5ca4cb84e0b6e1c47a5837ab9d0724181c68e1
parent966d3efddcb1da6496dd99ee06bce7a985a5419f (diff)
downloadsciteco-bc859a06a13b24daea12d35df2a1ec5114b42180.tar.gz
fixed rubout of empty forward kill (FK)
Test case: IF$ J IX$ FKF$ ^W The range to delete is empty, Scintilla would not generate an undo action, but SCI_UNDO would still be exected on rubout which removes the "X" too early. * We should really get rid of Scintilla undo actions as they are a source of trouble and complexity. There could be a custom undo token to undo SCI_DELETERANGE that automatically fetches the text that's going to be deleted and stores it in the token's data. This could replace most uses of SCI_UNDO. The rest is to undo insertions, which can easily be replaced with undo__teco_interface_ssm(SCI_DELETERANGE...). * We should really allow rubout tests in the test suite...
-rw-r--r--src/search.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/search.c b/src/search.c
index fbf15ac..bdf70b0 100644
--- a/src/search.c
+++ b/src/search.c
@@ -916,12 +916,12 @@ teco_state_search_kill_done(teco_machine_main_t *ctx, const teco_string_t *str,
if (teco_is_failure(search_state))
return &teco_state_start;
- gint dot = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0);
+ sptr_t dot = teco_interface_ssm(SCI_GETCURRENTPOS, 0, 0);
teco_interface_ssm(SCI_BEGINUNDOACTION, 0, 0);
if (teco_search_parameters.dot < dot) {
/* kill forwards */
- gint anchor = teco_interface_ssm(SCI_GETANCHOR, 0, 0);
+ sptr_t anchor = teco_interface_ssm(SCI_GETANCHOR, 0, 0);
if (teco_current_doc_must_undo())
undo__teco_interface_ssm(SCI_GOTOPOS, dot, 0);
@@ -929,18 +929,23 @@ teco_state_search_kill_done(teco_machine_main_t *ctx, const teco_string_t *str,
teco_interface_ssm(SCI_DELETERANGE, teco_search_parameters.dot,
anchor - teco_search_parameters.dot);
+
+ /* NOTE: An undo action is not always created. */
+ if (teco_current_doc_must_undo() &&
+ teco_search_parameters.dot != anchor)
+ undo__teco_interface_ssm(SCI_UNDO, 0, 0);
} else {
/* kill backwards */
teco_interface_ssm(SCI_DELETERANGE, dot, teco_search_parameters.dot - dot);
+
+ /* NOTE: An undo action is not always created. */
+ if (teco_current_doc_must_undo() &&
+ teco_search_parameters.dot != dot)
+ undo__teco_interface_ssm(SCI_UNDO, 0, 0);
}
teco_interface_ssm(SCI_ENDUNDOACTION, 0, 0);
teco_ring_dirtify();
- /* NOTE: An undo action is not always created. */
- if (teco_current_doc_must_undo() &&
- teco_search_parameters.dot != dot)
- undo__teco_interface_ssm(SCI_UNDO, 0, 0);
-
return &teco_state_start;
}