DESCRIPTION

Verify offset is valid before calling getStyleRangeAtOffset

Bug: 367937
Change-Id: I0c6b83748ad56216726b02032bfbff088042d05c


COMMENTS

author: Jaidyn Nichols
date: 2012-01-06 16:31:10.000000000

Uploaded patch set 4.

-------------------------------------
author: Brenden Conley
date: 2012-01-06 16:40:51.000000000

Patch Set 4:

Build Started https://hudson.eclipse.org/sandbox/job/egit.gerrit/2246/ 

-------------------------------------
author: Brenden Conley
date: 2012-01-06 16:54:47.000000000

Patch Set 4: I would prefer that you didn't submit this

Build Unstable 
 
https://hudson.eclipse.org/sandbox/job/egit.gerrit/2246/ : UNSTABLE

-------------------------------------
author: Sebastian Porter
date: 2012-01-07 07:56:15.000000000

Patch Set 4:

The fix works but I would simplify it: there's no need for an early return (and code duplication) if we just assign the style range if it is valid:

StyleRange r= null;
if (o < t.getCharCount())
    r= t.getStyleRangeAtOffset(o);

The code that follows handles the 'null' case as expected.


Kevin, I tried to upload a new patch here but couldn't figure out how to do this from EGit i.e. push so that it gets appended here.

-------------------------------------
author: Jaidyn Nichols
date: 2012-01-07 17:43:26.000000000

Patch Set 4:

I don't see the point in creating a new StyleRange variable and doing an instanceof check on it when we know an error case  is occurring.

-------------------------------------
author: Sebastian Porter
date: 2012-01-08 11:39:29.000000000

Patch Set 4:

What you says is true for the code flow, but you have to declare the variable and do the instanceof check in the code anyway. Compared to that, duplicate code is worse in my personal opinion.

-------------------------------------
author: Jaidyn Nichols
date: 2012-01-08 18:26:47.000000000

Patch Set 4:

I guess I just see things differently,  the new case being handled is an exceptional case, no style range is available at the current position.  This should be handled by resetting the cursor and returning immediately.

-------------------------------------
