# Code Comment: uncomment removing non-comment %-signs in e.g. LaTeX document

Bug #1396649 reported by Danna Gifford on 2014-11-26
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Low
Unassigned

### Bug Description

The code comment/uncomment plugin "Code Comment" is behaving unexpectedly. In LaTeX, % signs are used to indicate a comment, but are also used as the actual percent sign when escaped with a \ (e.g. 50\% is half, 25\% is one-quarter, etc...)

The uncomment part of the Code Comment plugin is removing % signs, even when they are not at the start of a line. This can break LaTeX code, as demonstrated with the following example

Steps to reproduce:
1. Open a new document
2. Copy/paste the LaTeX code below "Test case:"
3. Enable the Code Comment plugin under Preferences>Plugins
4. Under View>Highlight Mode..., Select LaTeX (or save file with a .tex extension)
5. Select all text in the document.
6. Press "shift-ctrl-m" or select from the menu Edit>Uncomment Code

Test case:
\documentclass{report}
\begin{document}
Here is some text you might type in LaTeX. $>99\%$ of lines in LaTeX look like this.
e.g. 50\% is half, 25\% is one-quarter
%Like all statistics, the above line is completely fabricated.
Here is a line with an in-line comment. %This is an inline comment and should not be removed.
%Here is a commented line with a percentage: 50\% means the same as half.
\end{document}

Expected result (% signs should only be removed from start of line):
\documentclass{report}
\begin{document}
Here is some text you might type in LaTeX. $>99\%$ of lines in LaTeX look like this.
e.g. 50\% is half, 25\% is one-quarter
Like all statistics, the above line is completely fabricated.
Here is a line with an in-line comment. %This is an inline comment and should not be removed.
Here is a commented line with a percentage: 50\% means the same as half.
\end{document}

Actual result (first % sign found on a line is being removed. Note missing % sign in lines 3, 4, 6. File won't compile now due to \$caused on line 3): \documentclass{report} \begin{document} Here is some text you might type in LaTeX.$>99\\$ of lines in LaTeX look like this.
e.g. 50\ is half, 25\% is one-quarter
Like all statistics, the above line is completely fabricated.
Here is a line with an in-line comment. This is an inline comment and should not be removed.
Here is a commented line with a percentage: 50\% means the same as half.
\end{document}

Work-around:
Do a find-replace with "^%" as the search query and "Match as regular expression" selected. This will match % only at the start of a line.

 Sebastien Bacher (seb128) wrote on 2015-10-08: #1

Thank you for taking the time to report this bug and helping to make Ubuntu better. The issue you are reporting is an upstream one and it would be nice if somebody having it could send the bug to the developers of the software by following the instructions at https://wiki.ubuntu.com/Bugs/Upstream/GNOME. If you have done so, please tell us the number of the upstream bug (or the link), so we can add a bugwatch that will inform us about its status. Thanks in advance.

 Changed in gedit (Ubuntu): importance: Undecided → Low