| Summary: | [typing] Enter before right parenthesis indents differently from Ctrl+I | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Rajesh <rthakkar> | ||||||||
| Component: | Text | Assignee: | Rajesh <rthakkar> | ||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||
| Severity: | normal | ||||||||||
| Priority: | P3 | CC: | daniel_megert, deepakazad | ||||||||
| Version: | 3.6 | Flags: | deepakazad:
review+
|
||||||||
| Target Milestone: | 3.7 M6 | ||||||||||
| Hardware: | All | ||||||||||
| OS: | All | ||||||||||
| Whiteboard: | |||||||||||
| Attachments: |
|
||||||||||
|
Description
Rajesh
Test Case 1:
1. paste
----------%<----------
int foo() {
return "".length();
}
----------%<----------
2. place caret after '(' on the return line
3. press 'Enter'
4. Ctrl+I
==> indent gets destroyed
Test Case 2:
1. paste
----------%<----------
public class Test {
private void helper2(boolean[] booleans) {
if (booleans[0]) {
}
}
}
----------%<----------
2. place caret before ')' on the if line
3. press 'Enter'
4. Ctrl+I
==> indent gets destroyed
Created attachment 188325 [details]
Patch
Besides adding a new test, I have modified 'testAnonymousIndentation2' in JavaHeuristicScannerTest.java.
Deepak, please make the first review. Rajesh, is there a reason for this check "if ((line != -1) && (line != fLine))" ?
The tests pass with the following code, and I cannot think of a case where this would fail.
-----------------------------------------------------------------------
if (matchParen) {
if (skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN)) {
fIndent= fPrefs.prefContinuationIndent;
return fPosition;
} else {
-----------------------------------------------------------------------
Created attachment 188497 [details] Patch (In reply to comment #4) > Rajesh, is there a reason for this check "if ((line != -1) && (line != fLine))" > ? > > The tests pass with the following code, and I cannot think of a case where this > would fail. > ----------------------------------------------------------------------- > if (matchParen) { > if (skipScope(Symbols.TokenLPAREN, Symbols.TokenRPAREN)) { > fIndent= fPrefs.prefContinuationIndent; > return fPosition; > } else { > ----------------------------------------------------------------------- Being over cautious and trying to be sure that it is a continuation scenario. But the following 2 lines (785/786) in the execution path already ensure this which is why none of the potential failure cases never occur - "if (isFirstTokenOnLine) matchParen= true;" Thx. New patch removes the check. (In reply to comment #5) > Created attachment 188497 [details] [diff] > Patch Please attach a patch with tests included. +1 for the fix. Created attachment 188512 [details]
Patch with tests.
(In reply to comment #7) > Created attachment 188512 [details] [diff] > Patch with tests. Committed to HEAD. . Thanks for the patch Rajesh. |