| Summary: | double-click after opening brace does not select all block | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Eric Jodet <eric_jodet> | ||||
| Component: | SWT | Assignee: | Felipe Heidrich <eclipse.felipe> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | alex.blewitt, bokowski, daniel_megert, Olivier_Thomann, philippe_mulet, Silenio_Quarti, snorthov, thatnitind, Tod_Creasey | ||||
| Version: | 3.3 | ||||||
| Target Milestone: | 3.3 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 63492 [details]
screen shot
This is caused by StyledText.handleMouseDown which cuts the offset provided by the MovementListener to the end of the current line: end = Math.min(lineEnd, getWordNext(start, SWT.MOVEMENT_WORD_END)); This breaks all contributed double-click listeners that spawn a line. NOTE: same is true for getting the previous offset: start = Math.max(lineOffset, getWordPrevious(offset, SWT.MOVEMENT_WORD_START)); StyledText should simply lift that restriction. Steve, I've targeted this to 3.3 since we need being fixed but better would be to have a fix asap since this impacts daily work for those that use double-click to select code blocks. The fix seems to be trivial. It also doesn't work when double-clicking after closing brace. This is a major drawback in the Java editor. I am suffering as well, and even blamed Dani by mistake... *** Bug 182322 has been marked as a duplicate of this bug. *** Here's another dup. Steve, could you fix this for the next I-build? The change shouldn't be too hard, the only thing to do is ensuring that triple-click still selects the line. From Olivier: It works fine in I20070403-1110, but the triple click doesn't work as expected. I believe the problem was introduced when trying to fix the issue with triple click. For info, the triple-click bug that was fixed in this time frame is: bug 14654. Investigating... OK, I changed the 2 lines of code in handleMouseDown() to be the following: start = Math.max(0, getWordPrevious(offset, SWT.MOVEMENT_WORD_START)); end = Math.min(getCharCount(), getWordNext(start, SWT.MOVEMENT_WORD_END)); start and end do need to be protected in case an application returns an incorrect value in getWordPrevious or getWordNext, but it seems that lineOffset and lineEnd are too restrictive. Clamping the values to be between 0 and getCharCount() lets them be valid values anywhere in the document. This is now released to HEAD and will be in Tuesday's I-build. I am not going to mark the bug fixed, though, until Felipe verifies the code when he gets back from vacation. Felipe owns StyledText, and he may have had some reason that I don't know about to max with lineOffset and min with lineEnd. Dani, please test the next I-build really well in this area. (or test the N-build on Monday if you want to make sure it's ok for Tuesday's I-build). Felipe, please verify that this fix didn't break something else, and if it's ok then please mark the bug fixed. Thanks, Car Verifified the fix and double and triple-click in N20070416-0010. SWT rules! *** Bug 183649 has been marked as a duplicate of this bug. *** I can't recall why I needed this range test here. Apparently it only needs to compute the line start and line end for triple click. Since everything is working I'll not change the code. |
Version: 3.3.0 Build id: I20070410-1043 J2RE 5.0 IBM J9 2.3 Windows XP x86-32 build j9vmwi3223-2007020 test scenario: - open a Java file - at the beginning of a method, or try block, place the cursor after the opening brace { - double click --> only the current line gets selected, whereas I expect the whole block to be selected. this works OK with an M6 build