Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 301023 - [projection][typing] "Backspace" key deleting something else
Summary: [projection][typing] "Backspace" key deleting something else
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M7   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-27 11:50 EST by future.open CLA
Modified: 2010-06-01 10:50 EDT (History)
4 users (show)

See Also:


Attachments
Suggested fix + testcase adjustment (3.00 KB, patch)
2010-03-08 08:27 EST, Anton Leherbauer CLA
no flags Details | Diff
Previous fix + additional tests (6.43 KB, patch)
2010-03-08 08:57 EST, Anton Leherbauer CLA
daniel_megert: iplog+
daniel_megert: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description future.open CLA 2010-01-27 11:50:19 EST
Build Identifier: M20090917-0800

Sometimes the "backspace" key does not delete intended text. This happens only when some of the code previous to the current line has been collapsed. Once we "un-collapse" the code block the backspace works fine.

This, I have seen it happen in PERL & Python plugin on Windows XP SP3 and C++ plugin on Linux and Windows XP SP3

Reproducible: Always

Steps to Reproduce:
1. Write some dummy cone in Python or C++ on Win XP or Linux(Ubuntu)
2. With respect to the current line collapse some part of the code that is before the current line
3.Try deleting some of the code on the current line using the backspace key. (It will delete some of the code in the collapsed part)
Comment 1 Dani Megert CLA 2010-01-27 11:55:47 EST
Seems to be an issue in the CDT Editor.
Comment 2 Anton Leherbauer CLA 2010-02-02 02:42:18 EST
I see this behavior when pressing backspace (or delete) in an empty line following the last folded section.

+ folded code[...]
  <Backspace>
  <EOF>

This is probably due to bug 165298.
Comment 3 Anton Leherbauer CLA 2010-03-08 06:37:05 EST
I am moving this back to platform.  Projections which include the last char of the document are not handled correctly.
In other words: The exclusive end offset of the last segment maps to the exclusive end offset of the corresponding fragment.  I.e. if the last segment does not represent the end of the master document, this mapping is wrong.

A potential solution is to maintain a 0-length segment representing the end of the master document.  This would also fix the problem mentioned in bug 165298 comment 3.
Comment 4 Anton Leherbauer CLA 2010-03-08 08:27:52 EST
Created attachment 161284 [details]
Suggested fix + testcase adjustment

This patch implements the suggested solution to maintain a master-slave mapping for the end-of-master-document offset.  
It is quite simple, but I had to adjust the assertions in ProjectDocumentTest wrt. well-formed segmentation and fragmentation to allow a zero length segment as last segment.
Comment 5 Anton Leherbauer CLA 2010-03-08 08:57:51 EST
Created attachment 161291 [details]
Previous fix + additional tests

I have added 2 tests which fail without the fix.
Comment 6 Dani Megert CLA 2010-03-19 11:24:05 EDT
Re comment 2: I cannot reproduce this example in the Java editor. Anton, can you provide more detailed example/steps?
Comment 7 Anton Leherbauer CLA 2010-03-22 03:39:23 EDT
(In reply to comment #6)
> Re comment 2: I cannot reproduce this example in the Java editor. Anton, can
> you provide more detailed example/steps?

It cannot reproduce with the Java editor either, because there is no way to create a projection at the end of the document (at least I cannot find a way), but it is reproducible with the C/C++ editor:

- Install CDT or use the CPP package
- Create a sample Hello World C project
- Enable Folding (Ctrl+Numpad_Divide) in the editor
- Collapse the main function
- Put cursor on last line
- Press backspace or try to insert a char
Comment 8 Dani Megert CLA 2010-03-22 05:18:44 EDT
>It cannot reproduce with the Java editor either, because there is no way to
>create a projection at the end of the document (at least I cannot find a way),
Here are the steps:
1. add new class
2. remove the class declaration + body
2. add some imports and collapse them

Now having said that and testing a bit more I can also see strangeness but not when pressing the backspace: when I type a char on the last line after the collapsed imports, it inserts that character at the wrong place. Actually, pressing Backspace is also a bit weird: it moves the caret.
Comment 9 Dani Megert CLA 2010-03-22 13:01:20 EDT
Thanks Anton for the patch!

Committed to HEAD.
Available in builds > N20100321-2000.
Comment 10 Markus Keller CLA 2010-06-01 10:50:17 EDT
This patch triggered bug 313972, which we're going to fix for 3.6RC4. Steps from comment 8 still work after the fix for bug 313972, and also shouldn't affect the other cases.