| Summary: | Tags for disabling/enabling CDT code formatter (feature) | ||
|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Timothee Fivaz <timothee.fivaz> |
| Component: | cdt-other | Assignee: | Marco Stornelli <marco.stornelli> |
| Status: | RESOLVED FIXED | QA Contact: | Doug Schaefer <cdtdoug> |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | 525747482, hahoangthach, jonah, marco.stornelli, sagie, timothee.fivaz, webmaster |
| Version: | Next | ||
| Target Milestone: | 9.7.0 | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| See Also: |
https://bugs.eclipse.org/bugs/show_bug.cgi?id=27079 https://git.eclipse.org/r/137067 https://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=a6d06902b1f2626f3fadbeeb55a52979af22262a https://git.eclipse.org/r/140489 |
||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 546391 | ||
|
Description
Timothee Fivaz
This would be really cool. I love how the code formatter cleans up my code but at times, I just want to keep things aligned differently like your example. Seems to be more common in the C world where we often deal with lists of constants. +1 , this is the reason that I have to disable auto format when saving. Would love to override formatter when needed. New Gerrit change created: https://git.eclipse.org/r/137067 I created a patch for this feature request. I cannot change the status assigning the bug to myself. Hi Marco, thanks for having a look at this. I have assigned the bug to you with a provisional target of 9.7.0. Marco, this is a significant new feature for CDT 9.7. Can you please add it to https://wiki.eclipse.org/CDT/User/NewIn97 (have a look at previous New and Noteworthy entries for an idea of what it can look like https://wiki.eclipse.org/CDT/User/NewInCDT) PS. If this is your first edit on the Wiki, you will probably be moderated. Let me know and I will clear you through the moderator queue. ok, tomorrow I'm going to add a note on the wiki, thanks for help. (In reply to Marco Stornelli from comment #7) > ok, tomorrow I'm going to add a note on the wiki, thanks for help. Great. And the thanks is to you :-) Gerrit change https://git.eclipse.org/r/137067 was merged to [master]. Commit: http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=a6d06902b1f2626f3fadbeeb55a52979af22262a *** Bug 327559 has been marked as a duplicate of this bug. *** *** Bug 425248 has been marked as a duplicate of this bug. ***
## I test this sample, but format has some problem
/* @formatter:off */
int xx2(){string s1="abc";string s2="def";}
/* @formatter:on */
/* @formatter:on */
int xx(){string s1="abc";string s2="def";}
/* @formatter:off */
## after format, the "}" is not at next line!
/* @formatter:off */
int xx2(){string s1="abc";string s2="def";}
/* @formatter:on */
/* @formatter:on */
int xx()
{
string s1 = "abc";
string s2 = "def";}
/* @formatter:off */
it seems ok, there's no stack concept, the formatter just use the latest tag, since the last one was off, the code is not formatted as expected New Gerrit change created: https://git.eclipse.org/r/140489 Hi Sun, I think I understand the problem you are reporting. I wrote a new unit test for your case that fails like this: junit.framework.ComparisonFailure: expected:<... string s2 = "def";[ ]} /* @formatter:off ...> but was:<... string s2 = "def";[]} /* @formatter:off ...> See https://git.eclipse.org/r/#/c/140489/ Marco or Sun can you review it please? However as this bug now refers to finished release can a new bug be created to track the fixes in 9.8.0 (or potentially 9.7.1 if we want to push that out)? ok, so the problem is the contrary, the brace is moved on next line. I didn't understand. I think the problem could be related to the ending of no format zone. Currently it is the start of "on comment". Actually reading again the docs maybe we should moving the end to the end of the comment because it says "the formatter is restored *after* the on comment". I will take a look. (In reply to Marco Stornelli from comment #16) > ok, so the problem is the contrary, the brace is moved on next line. Sorry, I am not sure I understand the comment. The brace *should* be moved onto the next line, but it isn't. > I didn't understand. I think the problem could be related to the ending of no > format zone. Currently it is the start of "on comment". Actually reading > again the docs maybe we should moving the end to the end of the comment > because it says "the formatter is restored *after* the on comment". I will > take a look. I have uploaded an additional minimized test case to show that the problem is the off comment, not the on comment. Ok, got it. The problem is the "new line" removed when scribe enters in inactive state. (In reply to Sun Quan from comment #12) > ## I test this sample, but format has some problem Hi Sun, Marco has now fixed your use case in Bug 546391. Thank you for reporting it. The fix will be available in CDT 9.8 |