TextView: Improve performance of cursor movement in long paragraphs
Currently, if you have a sufficiently long paragraph (well line of text) in GtkTextView, moving the cursor will basically lock up the application.
Seeing this in text editor (but you can reproduce with GTK 3/gedit) too via pango_layout_move_cursor_visually()
.
This is using the attached file in Text Editor, and trying to move the cursor one position to the right.
#0 0x00007ffff7a62dc0 in _pango_cairo_font_private_get_glyph_extents (cf_priv=<optimized out>, glyph=17, ink_rect=0x0, logical_rect=0x7fffffffc230) at ../../../../Projects/pango/pango/pangocairo-font.c:905
#1 0x00007ffff7afd28b in pango_glyph_string_extents_range (logical_rect=0x7fffffffc460, ink_rect=<optimized out>, font=0x194c400, end=122736, start=0, glyphs=0x21691e0) at ../../../../Projects/pango/pango/glyphstring.c:210
#2 pango_glyph_string_extents_range (glyphs=0x21691e0, start=0, end=122736, font=0x194c400, ink_rect=<optimized out>, logical_rect=0x7fffffffc460) at ../../../../Projects/pango/pango/glyphstring.c:164
#3 0x00007ffff7b0b71b in pango_layout_run_get_extents_and_height (run=0x27069f0, run_ink=run_ink@entry=0x0, run_logical=run_logical@entry=0x7fffffffc460, line_logical=line_logical@entry=0x0, height=height@entry=0x0) at ../../../../Projects/pango/pango/pango-layout.c:5634
#4 0x00007ffff7b12ff3 in pango_layout_iter_get_run_extents (logical_rect=0x7fffffffc460, ink_rect=0x0, iter=0x7fffffffc380) at ../../../../Projects/pango/pango/pango-layout.c:7838
#5 pango_layout_iter_get_run_extents (iter=0x7fffffffc380, ink_rect=0x0, logical_rect=0x7fffffffc460) at ../../../../Projects/pango/pango/pango-layout.c:7826
#6 0x00007ffff7b1389f in pango_layout_index_to_line_and_extents (layout=<optimized out>, index=2362, line_rect=line_rect@entry=0x7fffffffc450, run_rect=run_rect@entry=0x7fffffffc460) at ../../../../Projects/pango/pango/pango-layout.c:1925
#7 0x00007ffff7b13a03 in pango_layout_get_cursor_pos (layout=layout@entry=0x252d380, index=2362, strong_pos=strong_pos@entry=0x7fffffffc4e0, weak_pos=weak_pos@entry=0x0) at ../../../../Projects/pango/pango/pango-layout.c:2598
#8 0x00007ffff7b13db4 in pango_layout_line_get_cursors (line=line@entry=0x29c41e0, strong=strong@entry=1, cursors=cursors@entry=0x578040) at ../../../../Projects/pango/pango/pango-layout.c:2052
#9 0x00007ffff7b13fb4 in pango_layout_move_cursor_visually (layout=0x252d380, strong=strong@entry=1, old_index=<optimized out>, old_index@entry=0, old_trailing=<optimized out>, old_trailing@entry=0, direction=direction@entry=1, new_index=new_index@entry=0x7fffffffc5f8, new_trailing=0x7fffffffc5fc)
at ../../../../Projects/pango/pango/pango-layout.c:2147
#10 0x00007ffff745afac in gtk_text_layout_move_iter_visually (layout=0x2c136e0, iter=iter@entry=0x7fffffffc7c0, count=count@entry=1) at ../../../../Projects/gtk/gtk/gtktextlayout.c:3668
#11 0x00007ffff7470b74 in gtk_text_view_move_cursor (text_view=0x2bd2a50, step=GTK_MOVEMENT_VISUAL_POSITIONS, count=1, extend_selection=0) at ../../../../Projects/gtk/gtk/gtktextview.c:6475
#12 0x00007ffff7c9b7f2 in g_closure_invoke (closure=0xd42f10, return_value=0x7fffffffca40, n_param_values=4, param_values=0x2aa1c90, invocation_hint=0x7fffffffc990) at ../../../../Projects/glib/gobject/gclosure.c:832
#13 0x00007ffff7cae2ed in signal_emit_unlocked_R (node=<optimized out>, detail=0, instance=0x2bd2a50, emission_return=0x7fffffffca40, instance_and_params=0x2aa1c90) at ../../../../Projects/glib/gobject/gsignal.c:3860
#14 0x00007ffff740d5e8 in gtk_signal_action_emit_signal (error=0x7fffffffca38, handled=<synthetic pointer>, args=<optimized out>, signal=<optimized out>, widget=0x2bd2a50) at ../../../../Projects/gtk/gtk/gtkshortcutaction.c:826
#15 gtk_signal_action_activate (action=<optimized out>, flags=<optimized out>, widget=0x2bd2a50, args=<optimized out>) at ../../../../Projects/gtk/gtk/gtkshortcutaction.c:858