b4n commented on this pull request.
> +
+ if (data->found) {
+ ScintillaObject *sci = doc->editor->sci;
+
+ sci_start_undo_action(sci);
+
+ if (data->new_lines > 0) {
+ gint pos = sci_get_position_from_line(sci, data->new_start - 1);
+ sci_set_target_start(sci, pos);
+ pos = sci_get_position_from_line(sci, data->new_start +
data->new_lines - 1);
+ sci_set_target_end(sci, pos);
+ sci_replace_target(sci, "", FALSE);
+ }
+
+ if (data->old_lines > 0) {
+ gint line = sci_get_current_line (sci);
> `gint pos = sci_get_position_from_line (sci, data->new_start - 1);` returns
> the pos on the previous line which is wrong when undoing deleted-only diff -
> I need to advance it to the next line if `new_lines == 0` (see a few lines
> below).
Indeed, I was confused at first. I suggest
00e37457c20c94e23b1eef8ea98ea1977c446635
> Just to understand - what does scintilla return from sci_get_current_line()
> when you right-click somewhere - I'd expect it doesn't change the current
> line, does it?
No it doesn't, but Geany gives us the position of the right click, and other
features in the menu work at the click position, not the caret position. So
for the feature I want to do the same: propose undoing the diff at the right
click position, not at the caret one. See
0c4415dbe61792de805e45e72433e4feaac988f5 for a proposal.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/pull/531#discussion_r116390480