Login  Register

Strings are pasted in the wrong position in new text windows

Posted by Stein Rørvik on Jul 05, 2018; 7:48am
URL: http://imagej.273.s1.nabble.com/Strings-are-pasted-in-the-wrong-position-in-new-text-windows-tp5019715p5020908.html

I submitted to the list in January 2018 a bug in the way the clipboard is handled in the ImageJ built-in text editor. The issue as described was then resolved in daily build 1.51u15, but there is still a related problem (most likely windows-only) present with respect to the cursor position in newly made text windows.

Try this:

Copy some string to the clipboard from any application, e.g. MyString

Create a new text window (Ctrl-Shift-N) in ImageJ and then _type_ some text (do not paste) into multiple lines, e.g.

        This is line 1
        This is line 2

and then attempt to paste the string in your clipboard between these two lines (cursor at the start of line 2) by keyboard Ctrl-V or from the menu.

The result is

        This is line 1
        TMyStringhis is line 2

instead of the expected
        This is line 1
        MyStringThis is line 2

Obviously the cursor position is wrong by one position; if you have two lines before the cursor point the position gets two positions wrong:

        This is line 1
        This is line 2
        ThMyStringis is line 3

I assume this is a windows-only bug due to its common confusion from CR+LF line endings instead of just CR or LF.

The issue does not occur if the source text was copied from another application and pasted into the editor. For example, if you type the three line text in Notepad++ and paste into ImageJ, the subsequent pasting gets correct:

        This is line 1
        This is line 2
        MyStringThis is line 3

This problem only occurs with newly created text windows;
it does not happen if you paste into a text window that was opened from a file.

I am using daily build ImageJ 1.52e on Windows 7 64-bit.

Stein

-----Original Message-----
From: ImageJ Interest Group <[hidden email]> On Behalf Of Wayne Rasband
Sent: 17. januar 2018 05:02
To: [hidden email]
Subject: Re: Strings are pasted in the wrong position in new text windows

> On Nov 17, 2017, at 7:18 AM, Stein Rørvik <[hidden email]> wrote:
>
> There seems to be a bug in the way the clipboard is handled in the ImageJ built-in text editor.
>
> Try this:
>
> Copy some string to the clipboard from any application, e.g. MyString
>
> Create a new text window (Ctrl-Shift-N) in ImageJ and then type
> something (e.g. Test) and then paste the above string at the current
> cursor position (which is after your typed string) by keyboard Ctrl-V or from the menu.
>
> The result is MyStringTest instead of TestMyString

This Windows-only bug is fixed in the latest daily build (1.51u15).

-wayne

> The pasted position seems to always come at the start of the current line or at the start of the file.
> The result of this varies, depending on the length of the text already present before you try to paste.
>
> This problem only occurs with newly created text windows; it does not
> happen if you paste into a text window that was opened from a file.
>
> I am using daily build ImageJ 1.51s on Windows 7 64-bit.
>
> Stein

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html