Wrong effect when pressing Enter with text selected on indented line while auto-indent is enabled
This is a very specific case, but here are the steps to reproduce it:
Run the following script
Object.assign(imports.gi.versions, {
Gtk: '3.0',
GtkSource: '3.0',
});
const {Gtk, GtkSource} = imports.gi;
Gtk.init(null);
const w = new Gtk.Window({
defaultHeight: 600,
defaultWidth: 400,
});
const sv = new GtkSource.View({
autoIndent: true,
});
w.add(sv);
sv.buffer.text = ' foobar;';
w.connect('destroy', () => Gtk.main_quit());
w.show_all();
Gtk.main();
Select the letters "ob" with the mouse. The view looks like this, where ||
indicates the selection bounds:
fo|ob|ar;
Press Enter.
The view now looks like this:
fo|ob
|ar;
Subsequent presses of Enter keep extending the end bound of the selection.
Whereas, with auto-indent disabled, it looks like this after pressing Enter, which I would consider the expected behaviour (possibly with ar
indented if auto-indent is on, though):
fo
ar;
I've found it's the combination of auto-indent plus a selection in the middle of an indented line that causes the bug. This bug is also visible in org.gnome.gedit//stable from Flathub, with auto-indent turned on via the Editor preferences tab.
Edited by Philip Chimento