After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 750245 - completion: close environment in a different user action
completion: close environment in a different user action
Status: RESOLVED FIXED
Product: gnome-latex
Classification: Other
Component: general
unspecified
Other All
: Normal normal
: unspecified
Assigned To: LaTeXila maintainer(s)
LaTeXila maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2015-06-01 22:02 UTC by Stefano Facchini
Modified: 2015-06-12 13:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
completion: close environment in a different user action (960 bytes, patch)
2015-06-01 22:02 UTC, Stefano Facchini
needs-work Details | Review
completion: close environment in a different user action (1.64 KB, patch)
2015-06-03 17:10 UTC, Stefano Facchini
needs-work Details | Review
completion: close environment in a different user action (2.42 KB, patch)
2015-06-09 12:05 UTC, Stefano Facchini
none Details | Review

Description Stefano Facchini 2015-06-01 22:02:08 UTC
A behavior copied from Texmaker which I find quite useful.
Comment 1 Stefano Facchini 2015-06-01 22:02:12 UTC
Created attachment 304385 [details] [review]
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.
Comment 2 Sébastien Wilmet 2015-06-03 10:32:25 UTC
Review of attachment 304385 [details] [review]:

I agree with the proposal, but the patch needs a bit more work.

::: src/completion.vala
@@ +577,3 @@
             doc.insert (ref iter, "}", -1);
 
+        doc.end_user_action ();

The first begin_user_action() is not in the same function. So it's quite strange to end the user action here. It supposes that the caller has already called begin_user_action(). I prefer to have self-contained functions, that don't rely on things that the caller has already done.

So close_environment() should probably be split in two. For example ensure_bracket_is_closed() and close_environment(). In close_environment() we can have the begin/end_user_action. The caller would look like:

- begin_user_action()
- some inserts
- ensure_bracket_is_closed()
- end_user_action()
- close_environment() (which calls internally the begin/end_user_action)
Comment 3 Stefano Facchini 2015-06-03 17:10:28 UTC
Created attachment 304538 [details] [review]
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.
Comment 4 Stefano Facchini 2015-06-03 17:13:15 UTC
All the begin/end_user_action() are now in the calling function, so no more hidden assumptions.

As for ensuring the closed bracket, I can move it to a separate function if you prefer, but maybe it's not worth doing (it's used only here).
Comment 5 Sébastien Wilmet 2015-06-05 09:42:51 UTC
Review of attachment 304538 [details] [review]:

begin/end_user_action can be nested. So it's better to have them inside close_environment(), to group the actions.

You should also explain why there is two user actions in the code, not just in the commit message.
Comment 6 Stefano Facchini 2015-06-05 19:11:08 UTC
(In reply to Sébastien Wilmet from comment #5)
> Review of attachment 304538 [details] [review] [review]:
> 
> begin/end_user_action can be nested. So it's better to have them inside
> close_environment(), to group the actions.
> 

Sorry, I don't understand this. According to gtk+ documentation:
"GtkTextBuffer maintains a count of calls to gtk_text_buffer_begin_user_action() that have not been closed with a call to gtk_text_buffer_end_user_action(), and emits the “begin-user-action” and “end-user-action” signals only for the outermost pair of calls."




> You should also explain why there is two user actions in the code, not just
> in the commit message.

Ok
Comment 7 Sébastien Wilmet 2015-06-06 14:09:18 UTC
begin/end_user_action can be nested, for example:

- begin_user_action
- insert/delete text
- call close_environment(), which itself calls begin/end_user_action
- end_user_action

With the above example, you can combine user actions into bigger user actions.

But it's important that if you call close_environment() alone, it's a user action in itself, so that the caller doesn't need to surround the call of close_environment() with begin/end_user_action.
Comment 8 Stefano Facchini 2015-06-09 12:05:47 UTC
Created attachment 304850 [details] [review]
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.