gtoolkit icon indicating copy to clipboard operation
gtoolkit copied to clipboard

Code editor is confused by linefeed characters (pasted under Windows)

Open zeniko opened this issue 6 months ago • 1 comments

Copied text from most Windows applications contain line feed and carriage return ("\r\n" or 0x13 0x10).

Pasting such text into a code editor leads to unexpected behavior best observed when (un)indenting:

  • Hitting Ctrl+A, Shift+Tab raises a SubscriptOutOfBounds exception
  • Hitting Ctrl+A, Tab inserts new blank lines between each line and to compensate cuts off the last character of each line. E.g. pasting
def f():
	pass

and indenting leads to

	def f():
	
		pas
	
	

(the invisible s from pass seems to still be stored, though, and eventually appears on the next line when indenting further).

  • Once I also got a "Cursor not found in set" exception from simply clicking into the code editor.

This happens with text copied from Notepad or even this browser window under the latest GT build, not however with text copied from GT itself.

Maybe stripping/normalizing linefeeds when pasting text would be a sufficient fix.

zeniko avatar Jul 31 '25 20:07 zeniko

I second some type of normalization, maybe fix this at the GT clipboard level. The historical default line ending character in Smalltalks does not match the default in various OSes (Linux, Windows, not sure about MacOS). There is already some logic in other parts of GT that deals with these conversions so it should be added here too.

botwhytho avatar Aug 05 '25 20:08 botwhytho