Bug 14429 - Smoke 20020423: replace from local history wrong indentation
Summary: Smoke 20020423: replace from local history wrong indentation
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P1 normal (vote)
Target Milestone: ---   Edit
Assignee: Dirk Baeumer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-04-23 12:38 EDT by Dirk Baeumer CLA
Modified: 2002-04-24 06:46 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2002-04-23 12:38:43 EDT
- load TestCase.java
- edit method runTest
- save
- replace method with latest from local histroy
observe: the method is wrong indented

IMO the culprit is a change DB did at MemberEdit.
Comment 1 Dirk Baeumer CLA 2002-04-23 13:55:33 EDT
The problem has nothing to do with the change in MemberEdit. It is as follows:

the method runTest contains lines with no indentation. As a result the method 
removeIndentation doesn't remove any indentation. Thus we end up having two 
indentations.

To fix the problem the method that computes the indent of a code block must 
deal with empty lines and lines that only contain a new line.
Comment 2 Dirk Baeumer CLA 2002-04-23 14:12:12 EDT
The suggested fix is problematic since the member edit and the code formatter 
util don't know anything about line delimiters. The member edit API takes an 
array of lines and the initial assumption was that the lines don't contain line 
delimiters (but it isn't doced). There are helper methods on Strings and 
TextBuffer to convert a string or a range into an array of lines.

IMO we should fix as follows:

- MemberEdit assumes that the passed array of lines don't contain line
  delimiters. We doc that in the constructor
- CodeFormatterUtil treats empty lines correctly.

Andre what do you think ? Can you pass an array of line which don't contain 
line delimiters
Comment 3 Dirk Baeumer CLA 2002-04-24 06:46:29 EDT
Fixed in build > I20020423