Feedback 44939 - Pasting code into the code editor suddenly trims leading whitespace

I filed the case 44939 a few days ago, which now has been closed – IMHO wrongly.

There is a short mov-file showing that when you paste a text which starts with a space into the source code editor, the space gets truncated. Which I consider a bug.

What is your opinion on this?

The space stripping occured also for the end of the pasted string.

Example: put two slashed and an endind spacce in the clipboard and paste that to the code editor: the ending space is removed too.

I do not like that either.

I asked some weeks ago if there is a special reason behind that, but my question was certainly wrong / I do not had an answer (AFAIK).

Nota: I think this is not the only thing the IDE do at Paste time. I think he want to remove what he calls Gremlins characters (If I recall correctly, they are control characters: ASCII 0 to 31). I do not think at a good reason to not do that in this case.

There are situation where we as developer have to do that to our customers; say in a Date Field, a Country Field, etc. and even I am thinking at a double space replaced by a single space in some Fields. All of these fields will be stored in csv or sqlite files.

But, using Courier as the IDE font (in Preferences), I love to use spaces after the Comment character(s), as well using a bunch of ling dash in the Method / Functions Header to make a proper block of comments there, etc.

This is just my taste and I may be alone (or so) doing that… :frowning:

What annoys me most about it is that it used to work properly in earlier versions.

Possibly the reviewer missed what you’re pointing at, it’s fairly subtle.

Previously, if the text copied had no endoflines then leading spaces are preserved in the paste. Only if an endofline was included did the leading spaces get trimmed.

The change is that now all copied text has leading spaces trimmed.

I’m not sure when this changed though, only compared 13r3 and 16r2.

Many versions ago :frowning:

No. I use to copy slash slash space return (select the whole line in the Code Editor) and paste them many times… watch below:

// ---------- ---------- ---------- ---------- ---------- ---------- // // What this Method do // // a. // // // // b. // // ---------- ---------- ---------- // // Method: // Inputs: // Outputs: None // Syntax: () // // Created: 2016-08-19 13:00 // Creator: Emile Schwarz [] // // ---------- ---------- ---------- ---------- ---------- ---------- //

This was annoying too.

No IDE code editor is working like this. I don’t know who came up with implementing that, but this is one of the stupidest things ever introduced in Xojo.

If it’s of any help, I filed this case in May and it’s been marked as ‘verified’:


I find it irritating when copying and pasting code, so have added some points to it.

I always imagined the intent is that since Xojo automatically indents code then leading spaces are redundant. This way if you copy code from the forums and paste you aren’t left with a bunch of leadings spaces to delete. I think this makes sense (except when pasting into a Note or other note-like area). But when copy/pasting a single line (no endoflines) then I think all spaces should be preserved, how it used to be.

I don’t have trouble with this because I never use leading spaces in code. Doesn’t the automatic indentation always make it correct or are you going for a different indentation?

[quote]I filed the case 44939 a few days ago, which now has been closed – IMHO wrongly.

I agree with you… I have found that behavior VERY annoying but have been living with it along with the other annoyances of this IDE.

I want to cape EXACTLY what I copied ,not a trimmed version, asI copied it that way for a reason.


I find it important for search and replace, or when doing individual items in a method parameter list (I want the spaces to help legibility). There are other situations as well…

In any case I find myself annoyed by the new behavior fairly often.

  • Karen

I also agree. Very annoying.

I seem to waste a lot of time putting spaces back in manually, particularly when copying something onto the end of an existing line of code.

I just want to be clear, when pasting a single line I think spaces should be preserved (what’s broken). It’s only when pasting multiple lines that leading spaces can be trimmed.

As Karen has said: nothing should be trimmed. A code editor is not a word processor nannying the user.

Okay, have fun writing all your code in TextEdit.

Maybe I’m misunderstanding something here, but when I paste code then I want it properly aligned with the rest of the code, be it one line or 20.

i do not talk and never talk about LTRIM + RTRIM code lines.

My concern is… TRIM inside Code lines: characters after the comments character(s). Watch the example I shared above.

The copy paste is fixable
Currently if you save to a TEXT project your leading spaces & tabs will get ripped off when you reopen, make changes & save (try it)
This too is fixable
BUT it will mean that saving a project as text from this “fixed” version will have a huge number of changes in existing text projects since currently code is indented in text project files using a mix of tabs & spaces

AND if you go back to an older version, open & save it will rip them both out

And this behaviour isn’t new in text projects

So while you can / could insert leading spaces on lines of code they will disappear under certain circumstances no matter what I do

In my OP I was not talking about leading spaces pasted the beginning of a line, but pasted between characters in a line.

// I have that in the source editor (not the leading and the trailing space): def // I mark the 5 characters (leading space, d, e, f, trailing space) and copy it // I paste it into TextEdit or Word in the mid of a string "abcdef". Result: abc[space]def[space]ghi // I paste it into the source editor in the mid of a string "abcdef". Result: abcdef[space]ghi
The leading space of the string pasted in is eliminated. This is a bug. Although I could only test it with the last version of RB, I’m sure it was introduced lately, because I would have stumbled over it earlier.

It started about 2015r4

And I can fix the copy paste separately from fixing the loading of a file
Just that the loading behaviour will surprise some people (although that too is not new behaviour)