[latexila] completion: close environment in a different user action
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] completion: close environment in a different user action
- Date: Fri, 12 Jun 2015 13:20:36 +0000 (UTC)
commit 666bff0e71bb0083f4ab95b8f658bae32f8e77e7
Author: Stefano Facchini <stefano facchini gmail com>
Date: Mon Jun 1 23:45:12 2015 +0200
completion: close environment in a different user action
In this way, a user only interested in inserting the "\begin" part
can easily remove the "\end" by ctrl-z.
https://bugzilla.gnome.org/show_bug.cgi?id=750245
src/completion.vala | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/src/completion.vala b/src/completion.vala
index 639e861..644bf59 100644
--- a/src/completion.vala
+++ b/src/completion.vala
@@ -462,7 +462,20 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
// close environment: \begin{env} => \end{env}
if (arg_cmd == "\\begin")
+ {
+ // Close the bracket if needed.
+ if (iter.get_char () == '}')
+ iter.forward_char ();
+ else
+ doc.insert (ref iter, "}", -1);
+
+ // We close the environment in a different user action. In this way
+ // a user interested only in autocompleting the "\begin" command
+ // can easily remove the "\end" by undo.
+ doc.end_user_action ();
+ doc.begin_user_action ();
close_environment (text, iter);
+ }
// TODO place cursor, go to next argument, if any
else
@@ -476,17 +489,13 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
{
Document doc = iter.get_buffer () as Document;
- // Close the bracket if needed.
- if (iter.get_char () == '}')
- iter.forward_char ();
- else
- doc.insert (ref iter, "}", -1);
-
string cur_indent = doc.get_current_indentation (iter);
string indent = doc.tab.view.get_indentation_style ();
CompletionChoice? env = _environments[env_name];
+ doc.begin_user_action ();
+
doc.insert (ref iter, @"\n$cur_indent$indent", -1);
if (env != null && env.insert != null)
@@ -503,6 +512,8 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
doc.get_iter_at_mark (out iter, cursor_pos);
doc.delete_mark (cursor_pos);
doc.place_cursor (iter);
+
+ doc.end_user_action ();
}
/*************************************************************************/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]