Error in OSTextEdit>>#selectedText (off by one error)

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

Error in OSTextEdit>>#selectedText (off by one error)

Postby rjs » Fri Aug 13, 2010 4:19 am

When the text selection size is > 32,767, there is an off by one error IF the final line consists of nothing but the closing quote character. You get a walkback. Add an extra character at the beginning of that line and it is fine. Put the closing quote at the end of the previous line and it is fine.

I have only verified this in VAST 8.0.0. It is an oddball enough error that I suspect it still exists in 8.0.2 (given that the code has never been touched since 1996).
rjs
 
Posts: 39
Joined: Thu Mar 27, 2008 11:07 am
Location: Port Perry, Ontario, Canada

Re: Error in OSTextEdit>>#selectedText (off by one error)

Postby wembley » Thu Aug 19, 2010 7:12 am

Richard -

Actually the problem is a bit more pervasive than you suggest. It will occur whenever the size of the text in the OSTextEdit widget is > 32767, not the size of the selected text itself.

The solution is pretty simple -- rip out a pile of code that catered to Win95. The result is:
Code: Select all
OSTextEdit>>selectedText
   "Answer the selected text in the receiver."

   | selection startPoint endPoint lines line |

   selection := self osSelection.
   selection x = selection y
      ifTrue: [^''].  "$NON-NLS$"
   ^ (self osCopyFrom: selection x + 1 to: selection y) asString

Case 47397 has been opened and the fix is targetted for V8.0.3.
John O'Keefe [|], Principal Smalltalk Architect, Instantiations Inc.
wembley
Moderator
 
Posts: 405
Joined: Mon Oct 16, 2006 3:01 am
Location: Durham, NC

Re: Error in OSTextEdit>>#selectedText (off by one error)

Postby rjs » Sun Aug 22, 2010 2:25 am

Excellent!
That's a solution that is right in line with a code review heuristic I use: less is better. :-)
rjs
 
Posts: 39
Joined: Thu Mar 27, 2008 11:07 am
Location: Port Perry, Ontario, Canada


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: No registered users and 1 guest

cron