[ghex/gtk4-port: 88/91] gtkhex: fix cut behaviour
- From: Logan Rathbone <larathbone src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ghex/gtk4-port: 88/91] gtkhex: fix cut behaviour
- Date: Thu, 12 Aug 2021 23:35:12 +0000 (UTC)
commit a55d473c89742c86c6200aca003117ed9f38f1bc
Author: Logan Rathbone <poprocks gmail com>
Date: Wed Aug 11 15:37:42 2021 -0400
gtkhex: fix cut behaviour
src/gtkhex.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
---
diff --git a/src/gtkhex.c b/src/gtkhex.c
index fc56f5eb..6a42926b 100644
--- a/src/gtkhex.c
+++ b/src/gtkhex.c
@@ -2896,22 +2896,21 @@ gtk_hex_clear_selection(GtkHex *gh)
void
gtk_hex_delete_selection(GtkHex *gh)
{
- int start;
- int end;
+ int start, end, len;
start = MIN(gh->selection.start, gh->selection.end);
end = MAX(gh->selection.start, gh->selection.end);
+ len = end - start + 1;
+ g_assert (len);
+
gtk_hex_clear_selection (gh);
- if (start != end)
- {
- if (start < gh->cursor_pos)
- gtk_hex_set_cursor (gh, gh->cursor_pos - end + start);
+ if (start < gh->cursor_pos)
+ gtk_hex_set_cursor (gh, gh->cursor_pos - end + start);
- hex_document_delete_data (gh->document,
- MIN(start, end), end - start, TRUE);
- }
+ hex_document_delete_data (gh->document,
+ MIN(start, end), len, TRUE);
}
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]