Bug 217769 - [breakpoints] ToggleBreakpointAction always creates TextSelection with 0 lengh
Summary: [breakpoints] ToggleBreakpointAction always creates TextSelection with 0 lengh
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M6   Edit
Assignee: Michael Rennie CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2008-02-04 17:37 EST by Dan Heidinga CLA
Modified: 2008-02-12 10:26 EST (History)
1 user (show)

See Also:


Attachments
Patch replacing hardcoded 0 with region.getLength() (1.04 KB, patch)
2008-02-04 17:39 EST, Dan Heidinga CLA
no flags Details | Diff
Second attempt at fixing the problem. (2.70 KB, patch)
2008-02-05 17:43 EST, Dan Heidinga CLA
no flags Details | Diff
Same as R3_3_maintenance_ToggleBreakpointAction2.patch except against head (3.17 KB, patch)
2008-02-11 14:43 EST, Dan Heidinga CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Heidinga CLA 2008-02-04 17:37:46 EST
Build ID:  M20070921-1145

Steps To Reproduce:
1. Create a breakpoint using the Ruler double click
2. The ITextSelection will have a length of 0.

More information:
The call to the ITextSelection constructor has 0 hard-coded for the length.  The 0 should be replaced with a call to region.getLength().

This matters for languages that are able to set breakpoints by source position, in addition to by line number.

A patch fixing this is attached.
Comment 1 Dan Heidinga CLA 2008-02-04 17:39:19 EST
Created attachment 88839 [details]
Patch replacing hardcoded 0 with region.getLength()

Patch didn't add when opening item.
Comment 2 Dan Heidinga CLA 2008-02-05 13:42:36 EST
On further inspection, the patch I provided doesn't actually fix the problem - it now provides the length of the line, rather than the text selection.

I'll dig into it further.
Comment 3 Dan Heidinga CLA 2008-02-05 17:43:19 EST
Created attachment 88945 [details]
Second attempt at fixing the problem.

The problem was a little more complex then I first thought, but it breaks down into a couple of cases:

1.  No text is currently selected:
        >Create a TextSelection with 0 length based at an offset equal to the
         start of the line. (Original behaviour)
2.  Text is selected:
    A) Clicking on line outside the selection 
       (ie: highlight lines 2-3, but click on line 1)
        >Create a TextSelection with 0 length based at an offset equal to the
         start of the line.  (Original behaviour)
    B) Clicking on line inside the selection
       (ie: highlight lines 2-3, and click on either line 2 or 3)
        >Use the ISelection from the fPart's selectionProvider. (New Behaviour)
         The line number will be the starting line of the selection
         (ITextSelection.getStartLine())

Does this seem reasonable?
Comment 4 Michael Rennie CLA 2008-02-11 12:47:31 EST
Dan, could you remake the patch for HEAD, as it is now it does not apply.

Looking at the patch itself, it seems reasonable, as there is really only one change to an outlier case (when we actually have text selected on the current line).
Comment 5 Dan Heidinga CLA 2008-02-11 14:43:40 EST
Created attachment 89441 [details]
Same as R3_3_maintenance_ToggleBreakpointAction2.patch except against head

This is the same patch as R3_3_maintenance_ToggleBreakpointAction2.patch except this is against HEAD.
Comment 6 Michael Rennie CLA 2008-02-12 10:25:50 EST
applied patch, thanks Dan
Comment 7 Michael Rennie CLA 2008-02-12 10:26:02 EST
verified