[gnome-builder] source-view: avoid external jumps when possible
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] source-view: avoid external jumps when possible
- Date: Mon, 21 Dec 2015 08:02:27 +0000 (UTC)
commit c69b56df3ef821fcce73b1ae3e1e9fc25f24d249
Author: Christian Hergert <chergert redhat com>
Date: Sat Dec 5 23:13:23 2015 -0800
source-view: avoid external jumps when possible
libide/ide-source-view.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 3870100..a655167 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -4468,9 +4468,9 @@ ide_source_view_goto_definition_symbol_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
- IdeBuffer *buffer = (IdeBuffer *)object;
g_autoptr(IdeSourceView) self = user_data;
g_autoptr(IdeSymbol) symbol = NULL;
+ IdeBuffer *buffer = (IdeBuffer *)object;
g_autoptr(GError) error = NULL;
IdeSourceLocation *srcloc;
@@ -4489,10 +4489,12 @@ ide_source_view_goto_definition_symbol_cb (GObject *object,
if (srcloc != NULL)
{
-#ifdef IDE_ENABLE_TRACE
guint line = ide_source_location_get_line (srcloc);
guint line_offset = ide_source_location_get_line_offset (srcloc);
IdeFile *file = ide_source_location_get_file (srcloc);
+ IdeFile *our_file = ide_buffer_get_file (buffer);
+
+#ifdef IDE_ENABLE_TRACE
const gchar *filename = ide_file_get_path (file);
IDE_TRACE_MSG ("%s => %s +%u:%u",
@@ -4500,6 +4502,21 @@ ide_source_view_goto_definition_symbol_cb (GObject *object,
filename, line+1, line_offset+1);
#endif
+ /*
+ * If we are navigating within this file, just stay captive instead of
+ * potentially allowing jumping to the file in another editor.
+ */
+ if (ide_file_equal (file, our_file))
+ {
+ GtkTextIter iter;
+
+ gtk_text_buffer_get_iter_at_line_offset (GTK_TEXT_BUFFER (buffer),
+ &iter, line, line_offset);
+ gtk_text_buffer_select_range (GTK_TEXT_BUFFER (buffer), &iter, &iter);
+ ide_source_view_scroll_to_insert (self);
+ return;
+ }
+
g_signal_emit (self, signals [FOCUS_LOCATION], 0, srcloc);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]