Bug 17626 - Auto-format source removed newline at end of range
Summary: Auto-format source removed newline at end of range
Status: VERIFIED DUPLICATE of bug 12159
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 major (vote)
Target Milestone: 2.0 F2   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 16422 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-05-24 09:30 EDT by Randy Hudson CLA
Modified: 2002-06-03 11:51 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 Randy Hudson CLA 2002-05-24 09:30:46 EDT
If I swipe some text and the last character is a newline, autoformat will 
remove this newline.

This typically happens when using the keyboard and pressing Shift+Up to select 
the region to be formatted.

Perhaps the range should be trimmed of whitespace before the autoformat occurs.
Comment 1 Randy Hudson CLA 2002-05-24 09:32:25 EDT
On second thought, it should be trimmed of newlines only (or lines that are 
empty?), since Tabs are one of the thing being reformatted.
Comment 2 Erich Gamma CLA 2002-05-24 18:29:59 EDT
Martin is this our custom formatting strategy or the formatter?
Comment 3 Erich Gamma CLA 2002-05-24 20:28:32 EDT
*** Bug 16422 has been marked as a duplicate of this bug. ***
Comment 4 Martin Aeschlimann CLA 2002-05-29 12:58:03 EDT
i tried to reproduce but failed. can you maybe send a screenshot so I can see 
how much you selected, and where the cursor is?
Or maybe send me the file (it could be something with the used line delimiters).
Comment 5 Dan Berindei CLA 2002-05-29 13:48:38 EDT
On F1 the bug could be reproduced by moving the cursor at the beginning of a 
line, pressing Shift-ArrowDown and then Ctrl-O. The line next ot the selected 
line will move at the end of the selected line.
On build 20020528 this works ok, but you can still fool it by selecting a space 
at the beginning of the next line.
Comment 6 Randy Hudson CLA 2002-05-29 15:07:44 EDT
public boolean foo(){
  return (3 > 4)
    || (4 % 3 == 0);
<START_HERE>}

From <START_HERE> Press Shift+UP_ARROW twice, then autoformat.  I get:
public boolean foo(){
  return (3 > 4)
    || (4 % 3 == 0);}
Comment 7 Randy Hudson CLA 2002-05-29 15:11:08 EDT
I just read Dan's reply.  I originally suggested that the algorithm trim 
newlines only because whitespace is one of the things you might be trying to 
fix by autoformat.  But, I think the algorithm should trim *ALL* trailing 
whitespace, to handle Dan's case of selecting too much whitespace at the end.

The user probably only wants to autoformat the initial Tabs/Spaces.
Comment 8 Martin Aeschlimann CLA 2002-05-30 11:34:06 EDT
moving to jcore
Comment 9 Philipe Mulet CLA 2002-06-01 07:09:00 EDT
I am now getting:

public boolean foo() {
	return (3 > 4) || (4 % 3 == 0);
}

Closing, duplicate of bug 12159

*** This bug has been marked as a duplicate of 12159 ***
Comment 10 Kent Johnson CLA 2002-06-03 11:50:52 EDT
Verified.