From 46dc43f0dfa503125ec1d8cab0844e593f37ae20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Thu, 7 Dec 2006 15:13:49 +0000 Subject: [PATCH] Create new tm file object when changing the filetype of a document to avoid a confused tagmanager. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1057 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 13 ++++++++++++- src/document.c | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2194efc..8fa62fbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,18 @@ +2006-12-07 Enrico Tröger + + * src/document.c: Create new tm file object when changing the filetype + of a document to avoid a confused tagmanager. + + 2006-12-06 Enrico Tröger * src/sci_cb.c: Don't insert extra indentation in Python files after a - colon if the line is a comment. + colon if the line is a comment (closes #1609761). + * src/about.c, src/build.c, src/callbacks.c, src/document.c, + src/encodings.c, src/gb.c, src/keyfile.c, src/prefs.c, src/sci_cb.c, + src/search.c, src/symbols.c, src/ui_utils.c, src/utils.c, + src/utils.h: Removed utils_str_equal() and use g_str_equal() from + GLib because it does exactly the same. 2006-12-05 Enrico Tröger diff --git a/src/document.c b/src/document.c index fce79081..a872e3bb 100644 --- a/src/document.c +++ b/src/document.c @@ -1276,14 +1276,24 @@ static GString *get_project_typenames() } -/* sets the filetype of the the document (sets syntax highlighting and tagging) */ +/* sets the filetype of the document (sets syntax highlighting and tagging) */ void document_set_filetype(gint idx, filetype *type) { - if (! type || idx < 0) return; - if (type->id > GEANY_MAX_FILE_TYPES) return; + if (type == NULL || + ! DOC_IDX_VALID(idx) || + doc_list[idx].file_type == type) + return; geany_debug("%s : %s (%s)", doc_list[idx].file_name, type->name, doc_list[idx].encoding); doc_list[idx].file_type = type; + + // delete tm file object to force creation of a new one + if (doc_list[idx].tm_file != NULL) + { + tm_workspace_remove_object(doc_list[idx].tm_file, TRUE); + doc_list[idx].tm_file = NULL; + } + document_update_tag_list(idx, TRUE); type->style_func_ptr(doc_list[idx].sci);