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 637695 - allow comment/uncomment with gtksourceview editor
allow comment/uncomment with gtksourceview editor
Status: RESOLVED FIXED
Product: anjuta
Classification: Applications
Component: plugins: language-support-c-cpp-java
git master
Other Linux
: Normal enhancement
: ---
Assigned To: Naba Kumar
Anjuta maintainers
Depends on:
Blocks:
 
 
Reported: 2010-12-20 22:03 UTC by Florian Ludwig
Modified: 2011-01-07 22:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Comment/Uncomment function for anjuta's language-support-cpp-java plugin (5.82 KB, patch)
2011-01-06 14:06 UTC, Peter Hoffmann
needs-work Details | Review
Comment/Uncomment function for anjuta's language-support-cpp-java plugin (6.88 KB, patch)
2011-01-07 22:24 UTC, Peter Hoffmann
committed Details | Review

Description Florian Ludwig 2010-12-20 22:03:48 UTC
With the gtksourceview editor there is no function for commenting/uncommenting available.

A suggestion about default shortcut:
strg+m for commenting and shift+strg+m for uncommenting because those are the ones used in the gedit "code comment" plugin
Comment 1 Johannes Schmid 2010-12-23 17:04:03 UTC
Created a CodeIn task for it, maybe someone picks it up:
http://socghop.appspot.com/gci/task/show/google/gci2010/gnome/t129312363432
Comment 2 Peter Hoffmann 2011-01-06 14:06:55 UTC
Created attachment 177657 [details] [review]
Comment/Uncomment function for anjuta's language-support-cpp-java plugin

I have implemented this feature in the course of the related GCI task.
Comment 3 Johannes Schmid 2011-01-06 14:54:10 UTC
Review of attachment 177657 [details] [review]:

From the implementation that looks very good and clean. I have to test that later to day to be sure.

Thanks a lot.

Just a note: Please add a link to this to the CodeIn task (submitted work...) because otherwise I cannot close the task.
Comment 4 Johannes Schmid 2011-01-07 17:45:41 UTC
Review of attachment 177657 [details] [review]:

OK, this works quite fine, two smaller issues:

* When something was commented like this
  /* some comment */
then the indentation is lost (or at least one tab is lost) when uncommenting it. Maybe you need to move one iterator for the erase by one, it's a bit tricky because the point between characters.

* In a C++ file, hitting uncomment on a /* */ comments it additionally with // instead of removing the comment.

::: plugins/language-support-cpp-java/plugin.c
@@ +1450,3 @@
+		(g_str_equal (plugin->current_language, "C")))
+	{
+		if (g_str_has_prefix (text_stripped, "/*") &&

These should be surrounded by ianjuta_document_begin_undo_action() and ianjuta_document_end_undo_action()

@@ +1515,3 @@
+	if (is_commented)
+	{
+		ianjuta_editor_erase (editor, start_copy, end_copy, NULL);

Same as above with undo-action
Comment 5 Peter Hoffmann 2011-01-07 22:24:57 UTC
Created attachment 177790 [details] [review]
Comment/Uncomment function for anjuta's language-support-cpp-java plugin

This should fix the mentioned problems.

Concerning the undo action, this was already present in the previous patch in the function on_toggle_comment. Is it inappropriately placed there?
Comment 6 Johannes Schmid 2011-01-07 22:37:25 UTC
Review of attachment 177790 [details] [review]:

Yes, that works! Great!

Sorry to have missed the undo/redo stuff last time. It's fine where it is.

Commit: http://git.gnome.org/browse/anjuta/commit/?id=be39289b292bf616ccf77ba9c6420d36a0cba9ce