| Summary: | [typing] Spaces Only mode: Paste of commented code with wrong indentation | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | MH <mhilpert> |
| Component: | Text | Assignee: | JDT-Text-Inbox <jdt-text-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | minor | ||
| Priority: | P3 | CC: | a.t.hofkamp, daniel_megert, luis.dediego, markus.kell.r, sbouchet, Tom.Sardella |
| Version: | 2.1.2 | Keywords: | helpwanted |
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 2000 | ||
| Whiteboard: | stalebug | ||
|
Description
MH
*** Bug 66180 has been marked as a duplicate of this bug. *** even with Eclipse 3.0, when i copy a comment (that was indented) and paste this in a new line where the cursor is correctly is indented in a method (8 spaces), when i press STRG+V (for paste), the resulting comment slashes (//) start at the beginning of the line (column 0) and the comment text starts 8 spaces later ... This is a duplicate of bug 65841; could someone mark it as such? This still occurs in 3.0.1 Sure, the bug is till open ==> not fixed. Re comment 4: it's not quite the same problem: in bug 65841 spaces are added - we try to treat it as commented code (spaces are added). In this bug the spaces somehow got lost, the code gets reformatted. M.H. can you confirm that the bug reported in comment 0 and comment 4 differ? Comment 3 is indeed a duplicate of bug 65841. I guess it's another bug. Here's how you can reproduced the bug I described in comment #0: 1. In a method (that is indented) insert these 2 lines: System.out.println("test"); System.out.println("test"); 2. Comment them (e.g. Source > Toggle comment). Result is correct: // System.out.println("test"); // System.out.println("test"); 3. Select those 2 lines (e.g. with mouse), copy (CTRL+C), and insert them 2 lines below, the wrong result is: // System.out.println("test"); // System.out.println("test"); because 2 spaces are suddenly removed after each "//". Works for me using I20091103-0941. To reproduce comment 9 in HEAD, the code formatter's "Tab Policy" must be set to "Spaces only", and "Java > Editor > Typing > When pasting > Adjust indentation" must be turned on. I think the right fix for this would be to fix the Toggle Comment command: If a line starts with more than two spaces, then don't just prepend "//", but replace the first two spaces by "//". The proposed solution in comment #11 looks wrong to me, since it means that commented code that did not move has 2 additional spaces indented compared to commented code that was moved. In my view all commented code should have the same amount of indenting. Two additional spaces would probably be easiest, as manually prefixing a line with "//" (in column 0) would then also have the same result. However, I can imagine that some people prefer not having additional white space in commented code. Perhaps when moving/copying a block of commented code, uncomment it, move/copy, and add comments again? That should give consistent results in every case. Yes, that's the workaround for me. BUt it's a workaround that involves more clicks than necessary. Toggle comments should be very simple: add 2 slashes and remove 2 slashes - each time at the beginning of the lines no matter if the line starts with spaces or not. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |