[gnome-builder] libide: special case deletion at end of buffer
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: special case deletion at end of buffer
- Date: Tue, 24 Mar 2015 00:12:49 +0000 (UTC)
commit 52f46d106af20cbeb748688f57430dc93e6140c0
Author: Christian Hergert <christian hergert me>
Date: Wed Mar 11 17:53:32 2015 -0700
libide: special case deletion at end of buffer
libide/ide-source-view.c | 24 ++++++++++++++++++++++--
1 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 846e2ae..1913b3e 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -2038,14 +2038,34 @@ ide_source_view_real_delete_selection (IdeSourceView *self)
{
GtkTextView *text_view = (GtkTextView *)self;
GtkTextBuffer *buffer;
+ GtkTextIter begin;
+ GtkTextIter end;
gboolean editable;
g_assert (IDE_IS_SOURCE_VIEW (self));
g_assert (GTK_IS_TEXT_VIEW (text_view));
- editable = gtk_text_view_get_editable (text_view);
buffer = gtk_text_view_get_buffer (text_view);
- gtk_text_buffer_delete_selection (buffer, TRUE, editable);
+ editable = gtk_text_view_get_editable (text_view);
+
+ if (!editable)
+ return;
+
+ gtk_text_buffer_get_selection_bounds (buffer, &begin, &end);
+
+ gtk_text_iter_order (&begin, &end);
+
+ if (gtk_text_iter_is_end (&end) && gtk_text_iter_starts_line (&begin))
+ {
+ gtk_text_buffer_begin_user_action (buffer);
+ gtk_text_iter_backward_char (&begin);
+ gtk_text_buffer_delete (buffer, &begin, &end);
+ gtk_text_buffer_end_user_action (buffer);
+ }
+ else
+ {
+ gtk_text_buffer_delete_selection (buffer, TRUE, editable);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]