[gnome-builder] editor: skip initial whitespace upon scroll_to_line_offset()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor: skip initial whitespace upon scroll_to_line_offset()
- Date: Fri, 2 Feb 2018 02:12:22 +0000 (UTC)
commit 586cb445ce73add5d12b4da58fc5c9ea0439a9cd
Author: Christian Hergert <chergert redhat com>
Date: Thu Feb 1 18:12:01 2018 -0800
editor: skip initial whitespace upon scroll_to_line_offset()
When scrolling to a line and offset, we want to skip past initial spaces
when line_offset is zero. This improves the natural case of "just go to
this line" and expect to be at the beginning text.
src/libide/editor/ide-editor-view.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
diff --git a/src/libide/editor/ide-editor-view.c b/src/libide/editor/ide-editor-view.c
index 23e4048d0..e0f1167cc 100644
--- a/src/libide/editor/ide-editor-view.c
+++ b/src/libide/editor/ide-editor-view.c
@@ -1088,6 +1088,9 @@ ide_editor_view_scroll_to_line (IdeEditorView *self,
* This will move the insert cursor.
*
* Lines and offsets start from 0.
+ *
+ * If @line_offset is zero, the first non-space character of @line will be
+ * used instead.
*/
void
ide_editor_view_scroll_to_line_offset (IdeEditorView *self,
@@ -1104,6 +1107,17 @@ ide_editor_view_scroll_to_line_offset (IdeEditorView *self,
gtk_text_buffer_get_iter_at_line_offset (GTK_TEXT_BUFFER (self->buffer), &iter,
line, line_offset);
+
+ if (line_offset == 0)
+ {
+ while (!gtk_text_iter_ends_line (&iter) &&
+ g_unichar_isspace (gtk_text_iter_get_char (&iter)))
+ {
+ if (!gtk_text_iter_forward_char (&iter))
+ break;
+ }
+ }
+
gtk_text_buffer_select_range (GTK_TEXT_BUFFER (self->buffer), &iter, &iter);
ide_source_view_scroll_to_insert (self->source_view);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]