Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions xed/xed-window.c
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,8 @@ update_cursor_position_statusbar (GtkTextBuffer *buffer,
GtkTextIter start;
guint tab_size;
XedView *view;
gchar *line_start_text;
const gchar *p;

xed_debug (DEBUG_WINDOW);

Expand All @@ -1791,20 +1793,26 @@ update_cursor_position_statusbar (GtkTextBuffer *buffer,

tab_size = gtk_source_view_get_tab_width (GTK_SOURCE_VIEW(view));

while (!gtk_text_iter_equal (&start, &iter))
/* Walk a plain C string instead of stepping a GtkTextIter one character
* at a time: each GtkTextIter call re-validates the iterator and does a
* BTree lookup, which gets very slow on long lines (e.g. minified code).
*/
line_start_text = gtk_text_iter_get_slice (&start, &iter);

for (p = line_start_text; *p != '\0'; p = g_utf8_next_char (p))
{
/* FIXME: Are we Unicode compliant here? */
if (gtk_text_iter_get_char (&start) == '\t')
if (g_utf8_get_char (p) == '\t')
{
col += (tab_size - (col % tab_size));
}
else
{
++col;
}
gtk_text_iter_forward_char (&start);
}

g_free (line_start_text);

xed_statusbar_set_cursor_position (XED_STATUSBAR(window->priv->statusbar), row + 1, col + 1);
}

Expand Down