fyne icon indicating copy to clipboard operation
fyne copied to clipboard

Paste multiline text into a multilineEntry sometimes ignores newlines

Open MikeHawkesCapventis opened this issue 11 months ago • 8 comments

Checklist

  • [X] I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • [X] This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

Create a NewMultilineEntry, textStyle monospace, wrapping off, tabWidth of 2. Copy a few lines of code from something like Vim, VSC etc., paste and the code arrives as a single line with all newlines ignored.

How to reproduce

	// Create entry form.
	input := widget.NewMultiLineEntry()
	input.TextStyle.Monospace = true
	input.TextStyle.TabWidth = 2
	input.Wrapping = fyne.TextWrapOff
	input.SetPlaceHolder("Enter script here...")

Sometimes it accepts a paste, sometimes it doesn't.

Screenshots

Visual studio code file text: Screenshot 2024-03-07 at 09 13 27

Result: Screenshot 2024-03-07 at 09 13 15

Example code

	// Create entry form.
	input := widget.NewMultiLineEntry()
	input.TextStyle.Monospace = true
	input.TextStyle.TabWidth = 2
	input.Wrapping = fyne.TextWrapOff
	input.SetPlaceHolder("Enter script here...")

Fyne version

v2 2.4.4

Go compiler version

go1.22.1 darwin/amd64

Operating system and version

MacOs Sonoma 14.3.1 (23D60)

Additional Information

No response

MikeHawkesCapventis avatar Mar 07 '24 09:03 MikeHawkesCapventis

Can you add a text snippet here that we can copy to replicate with?

@latest pulled today

Would you mind specifying the exact version for future’s sake? The latest version will be wrong as soon as we release a new one.

Jacalz avatar Mar 07 '24 10:03 Jacalz

I wonder, is your file formatted with CLRF (Windows style) line endings?

Jacalz avatar Mar 07 '24 10:03 Jacalz

Sorry - of course: fyne.io/fyne/v2 v2.4.4

MikeHawkesCapventis avatar Mar 07 '24 10:03 MikeHawkesCapventis

Not as far as I can tell on the Windows-style text. I used sed to create a CR/LF pair to try that - it gave a double-space view in VSC but the same result (single line) in the multiline. I've tried pasting from Vim vs VSC, from Notes, from raw terminal (cat the file copy/paste). It's intermittent and I can't quite work out what triggers it to work, but once it does work, it seems reasonably consistent - restart the app, and it's pot-luck as to whether paste works properly or not.

MikeHawkesCapventis avatar Mar 07 '24 10:03 MikeHawkesCapventis

Vscode has a setting to change line ending for at down in the bottom right, I think. Can you double check what it is set to?

Jacalz avatar Mar 07 '24 10:03 Jacalz

UTF-8 LF at the moment.

MikeHawkesCapventis avatar Mar 07 '24 10:03 MikeHawkesCapventis

How often does this happen? "sometimes" is hard to know if we can or cannot replicate locally sorry.

andydotxyz avatar Apr 23 '24 14:04 andydotxyz

Often ... very often. I'm building on an Apple MacBook Pro and running on an assortment of machines. It's fails more often than it succeeds. Weirdly, if it works, then it works for most of the time the app runs, but next time you start the app, it's back to failing more often than it runs. I've tried cut/pasting from all kinds of different source apps (terminal, VSCode, Notes, Word), and the source makes no difference.

MikeHawkesCapventis avatar Apr 23 '24 15:04 MikeHawkesCapventis