Clean up tags info when changing language

master
Yevgen Muntyan 2006-04-14 05:09:12 -05:00
parent 3d7e430c23
commit ff4c345d62
3 changed files with 28 additions and 0 deletions

View File

@ -468,3 +468,23 @@ moo_line_buffer_get_line_index (G_GNUC_UNUSED LineBuffer *line_buf,
g_assert (line == moo_line_buffer_get_line (line_buf, index));
return index;
}
void
moo_line_buffer_cleanup (LineBuffer *line_buf)
{
guint i, size;
g_return_if_fail (line_buf != NULL);
size = moo_text_btree_size (line_buf->tree);
for (i = 0; i < size; ++i)
{
Line *line = moo_line_buffer_get_line (line_buf, i);
moo_line_erase_segments (line);
g_slist_free (line->hl_info->tags);
line->hl_info->tags = NULL;
line->hl_info->tags_applied = FALSE;
}
}

View File

@ -67,6 +67,8 @@ struct _HLInfo {
LineBuffer *moo_line_buffer_new (void);
void moo_line_buffer_free (LineBuffer *line_buf);
void moo_line_buffer_cleanup (LineBuffer *line_buf);
Line *moo_line_buffer_get_line (LineBuffer *line_buf,
int index);

View File

@ -705,6 +705,7 @@ moo_text_buffer_set_lang (MooTextBuffer *buffer,
moo_lang_unref (old_lang);
moo_highlighter_destroy (buffer->priv->hl, TRUE);
moo_line_buffer_cleanup (buffer->priv->line_buf);
buffer->priv->lang = lang;
@ -751,9 +752,14 @@ moo_text_buffer_set_highlight (MooTextBuffer *buffer,
return;
if (buffer->priv->do_highlight && buffer->priv->lang)
{
moo_highlighter_destroy (buffer->priv->hl, TRUE);
moo_line_buffer_cleanup (buffer->priv->line_buf);
}
else
{
moo_highlighter_destroy (buffer->priv->hl, FALSE);
}
buffer->priv->do_highlight = highlight;