Fix bug with Go to tag defn/decl when the filename is a link (TagManager dereferences linked filenames)

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@421 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2006-06-07 21:24:15 +00:00
parent e62ba3d4c0
commit 79b4256758
6 changed files with 18 additions and 10 deletions

View File

@ -5,6 +5,9 @@
* src/callbacks.c, src/sciwrappers.c, src/sciwrappers.h: * src/callbacks.c, src/sciwrappers.c, src/sciwrappers.h:
Use the character position under the mouse click for Go to Use the character position under the mouse click for Go to
definition/declaration and for overridden middle click text paste. definition/declaration and for overridden middle click text paste.
* src/utils.c, src/utils.h, src/callbacks.c, src/document.c,
src/document.h: Fix bug with Go to tag defn/decl when the filename
is a link (TagManager dereferences linked filenames)
2006-06-06 Enrico Troeger <enrico.troeger@uvena.de> 2006-06-06 Enrico Troeger <enrico.troeger@uvena.de>

View File

@ -1318,6 +1318,7 @@ on_goto_tag_activate (GtkMenuItem *menuitem,
{ {
if (! utils_goto_workspace_tag( if (! utils_goto_workspace_tag(
TM_TAG(tags->pdata[i])->atts.entry.file->work_object.file_name, TM_TAG(tags->pdata[i])->atts.entry.file->work_object.file_name,
TRUE,
TM_TAG(tags->pdata[i])->atts.entry.line)) TM_TAG(tags->pdata[i])->atts.entry.line))
{ {
utils_beep(); utils_beep();
@ -1372,7 +1373,7 @@ on_tree_view_button_press_event (GtkWidget *widget,
gtk_tree_model_get(model, &iter, 0, &line, 1, &file, -1); gtk_tree_model_get(model, &iter, 0, &line, 1, &file, -1);
if (file && strlen (file) > 0) if (file && strlen (file) > 0)
{ {
utils_goto_workspace_tag(file, line); utils_goto_workspace_tag(file, FALSE, line);
} }
g_free(file); g_free(file);
} }

View File

@ -54,8 +54,10 @@
/* returns the index of the notebook page which has the given filename */ /* returns the index of the notebook page which has the given filename
gint document_find_by_filename(const gchar *filename) * is_tm_filename is needed when passing TagManager filenames because they are
* dereferenced, and would not match the link filename. */
gint document_find_by_filename(const gchar *filename, gboolean is_tm_filename)
{ {
guint i; guint i;
@ -63,11 +65,13 @@ gint document_find_by_filename(const gchar *filename)
for(i = 0; i < GEANY_MAX_OPEN_FILES; i++) for(i = 0; i < GEANY_MAX_OPEN_FILES; i++)
{ {
gchar *dl_fname = (is_tm_filename) ? doc_list[i].tm_file->file_name :
doc_list[i].file_name;
#ifdef GEANY_WIN32 #ifdef GEANY_WIN32
// ignore the case of filenames and paths under WIN32, causes errors if not // ignore the case of filenames and paths under WIN32, causes errors if not
if (doc_list[i].file_name && ! strcasecmp(doc_list[i].file_name, filename)) return i; if (dl_fname && ! strcasecmp(dl_fname, filename)) return i;
#else #else
if (doc_list[i].file_name && utils_strcmp(doc_list[i].file_name, filename)) return i; if (dl_fname && utils_strcmp(dl_fname, filename)) return i;
#endif #endif
} }
return -1; return -1;
@ -439,7 +443,7 @@ void document_open_file(gint idx, const gchar *filename, gint pos, gboolean read
} }
// if file is already open, switch to it and go // if file is already open, switch to it and go
idx = document_find_by_filename(utf8_filename); idx = document_find_by_filename(utf8_filename, FALSE);
if (idx >= 0) if (idx >= 0)
{ {
gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook), gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook),

View File

@ -26,7 +26,7 @@
/* returns the index of the notebook page which has the given filename */ /* returns the index of the notebook page which has the given filename */
gint document_find_by_filename(const gchar*); gint document_find_by_filename(const gchar*, gboolean is_tm_filename);
/* returns the index of the notebook page which has sci */ /* returns the index of the notebook page which has sci */

View File

@ -457,10 +457,10 @@ gint utils_get_local_tag(gint idx, const gchar *qual_name)
} }
gboolean utils_goto_workspace_tag(const gchar *file, gint line) gboolean utils_goto_workspace_tag(const gchar *file, gboolean is_tm_filename, gint line)
{ {
gint page_num; gint page_num;
gint file_idx = document_find_by_filename(file); gint file_idx = document_find_by_filename(file, is_tm_filename);
gboolean ret; gboolean ret;
if (file_idx < 0) return FALSE; if (file_idx < 0) return FALSE;

View File

@ -59,7 +59,7 @@ const GList *utils_get_tag_list(gint idx, guint tag_types);
gint utils_get_local_tag(gint idx, const gchar *qual_name); gint utils_get_local_tag(gint idx, const gchar *qual_name);
gboolean utils_goto_workspace_tag(const gchar *file, gint line); gboolean utils_goto_workspace_tag(const gchar *file, gboolean is_tm_filename, gint line);
gboolean utils_goto_line(gint idx, gint line); gboolean utils_goto_line(gint idx, gint line);