[8.5.2] EtWorkspace>>#displayEvaluatedSelectionIn: defect when the text pane is empty

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[8.5.2] EtWorkspace>>#displayEvaluatedSelectionIn: defect when the text pane is empty

Richard Sargent
Administrator
From a case of fumble fingers (hitting Ctrl-D instead of Ctrl-S), I discovered this error in EtWorkspace>>#displayEvaluatedSelectionIn: (StsPowerTools).

It might be more accurate to report CwText>>#stsLocationOfLineUnderCursor as the source of the error, since it returns nil in some cases instead of the usual Point.

(The practice returning nil is one of the worst anti-patterns, since it is never clear. If a method cannot return the right type under some conditions, it should have an exception block argument, following the #at: / #at:ifAbsent: pattern.)

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] EtWorkspace>>#displayEvaluatedSelectionIn: defect when the text pane is empty

Seth Berman
Hi Richard,

Thanks...opened case 53499 for this issue.

I agree with your point about answering nil.  
This won't break when using Scintilla editors because it will always answer a Point.  For empty lines , this is just a point whose x and y are the same value.  This value being the character location of the beginning of the current cursor line in the document.  For a doc with a bunch of empty lines on windows (<Cr><Lf>), the first line would be 0@0, second line 2@2 and so on.

I will change CwText>>stsLocationOfLineUnderCursor to model the CwScintillaEditor behavior

I will also fix a second issue I see, which is that it still attempts to evaluate the computed empty selection and always prints "nil" on the first line.  This is because it expects a non-empty selection, and will call #getSelectionPosition which always returns 0@0 for empty selections.  Attempting to evaluate an empty line is not going to produce anything useful, so I will probably have it check for empty selections and just bail if that's true.

-- Seth

On Wednesday, January 29, 2014 5:32:55 PM UTC-5, Richard Sargent wrote:
From a case of fumble fingers (hitting Ctrl-D instead of Ctrl-S), I discovered this error in EtWorkspace>>#displayEvaluatedSelectionIn: (StsPowerTools).

It might be more accurate to report CwText>>#stsLocationOfLineUnderCursor as the source of the error, since it returns nil in some cases instead of the usual Point.

(The practice returning nil is one of the worst anti-patterns, since it is never clear. If a method cannot return the right type under some conditions, it should have an exception block argument, following the #at: / #at:ifAbsent: pattern.)

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] EtWorkspace>>#displayEvaluatedSelectionIn: defect when the text pane is empty

Richard Sargent
Administrator

That sounds good.
(It's amazing what you can find when doing something very different from the usual application. )

On Feb 2, 2014 1:21 PM, "Seth Berman" <[hidden email]> wrote:
Hi Richard,

Thanks...opened case 53499 for this issue.

I agree with your point about answering nil.  
This won't break when using Scintilla editors because it will always answer a Point.  For empty lines , this is just a point whose x and y are the same value.  This value being the character location of the beginning of the current cursor line in the document.  For a doc with a bunch of empty lines on windows (<Cr><Lf>), the first line would be 0@0, second line 2@2 and so on.

I will change CwText>>stsLocationOfLineUnderCursor to model the CwScintillaEditor behavior

I will also fix a second issue I see, which is that it still attempts to evaluate the computed empty selection and always prints "nil" on the first line.  This is because it expects a non-empty selection, and will call #getSelectionPosition which always returns 0@0 for empty selections.  Attempting to evaluate an empty line is not going to produce anything useful, so I will probably have it check for empty selections and just bail if that's true.

-- Seth

On Wednesday, January 29, 2014 5:32:55 PM UTC-5, Richard Sargent wrote:
From a case of fumble fingers (hitting Ctrl-D instead of Ctrl-S), I discovered this error in EtWorkspace>>#displayEvaluatedSelectionIn: (StsPowerTools).

It might be more accurate to report CwText>>#stsLocationOfLineUnderCursor as the source of the error, since it returns nil in some cases instead of the usual Point.

(The practice returning nil is one of the worst anti-patterns, since it is never clear. If a method cannot return the right type under some conditions, it should have an exception block argument, following the #at: / #at:ifAbsent: pattern.)

--
You received this message because you are subscribed to a topic in the Google Groups "VA Smalltalk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/va-smalltalk/qzLsrdhvfMw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/groups/opt_out.