Jump to content

Copy paste in code block double the empty lines


Recommended Posts

Hello,

When I copy code from an editor (Notepad+++, PyCharm etc.) and paste it into an Evernote code block, all empty lines are doubled. If there is an empty line, in the block I will get two instead. Two empty lines, the code block will create four.

If I paste the code without block, just in the body of the note, no problem but if I select this code and click on the "block code" button to format it, the empty lines are duplicated.

I've had the problem for a few versions. I am in version 6.18.4.8489 (308489) Public (CE Build ce-62.3.7750)

and I'm on Windows 10 64bits.

Do others reproduce the same concern?

See the attached files.

Thanks for your help, this bug is very annoying for me.

Tim

2019-05-24_21h04_50.png

2019-05-24_21h06_01.png

2019-05-24_21h06_15.png

Link to comment
  • 8 months later...

Same issue here, for a long time already. I verified that this is with plain text copy, there is no formatting that can mess it up, and it doesn't matter if the line endings in clipboard are CRLF or LF, and Ctrl+Shift+V makes no difference to Ctrl+V :(

 

EDIT: This even happens when copying from the code block into itself! Every time, empty lines get doubled again and again.

This is a major issue for me, and it exists for so long already, is there any chance it will be looked at some time soon?

 

EDIT2: There is now a workaround!

Link to comment
On 2/16/2020 at 5:50 PM, CherryDT said:

Same issue here, for a long time already. I verified that this is with plain text copy, there is no formatting that can mess it up, and it doesn't matter if the line endings in clipboard are CRLF or LF, and Ctrl+Shift+V makes no difference to Ctrl+V :(

 

EDIT: This even happens when copying from the code block into itself! Every time, empty lines get doubled again and again.

This is a major issue for me, and it exists for so long already, is there any chance it will be looked at some time soon?

Thanks so much for your post @CherryDT, I'm glad I'm not the only one into this situation! (I thought I was crazy!^^).

It is a very big issue for me aswell. I started to paste my code into other software but I regret so much being able to do it into Evernote.

Please please Evernote teams, look into this very annoying bug that wasn't there a few updates ago.

Tim

 

 

Link to comment
  • Level 5*
On 2/18/2020 at 12:02 PM, Pozinux said:

Thanks for your answer but for me your test doesn't show the problem because you don't have empty lines.

Yeah, I missed that, and so got it wrong. Sorry about that. So I went back and retried. I see the problem with NotePad++, but curiously, when pasting direct from Visual Studio, no blank lines result.

So I checked into what's actually on the clipboard, using the third-party ClipSpy utility. Here's what I see, given and original clip of the following from NP++ and VS:

auto 1 = 3;

auto j = 4;

[Gah! The forum code formatting here clips off any trailing blank lines. There was originally one after the 'auto j' lines as well).

Anyways, here are the ClipSpy results:

VS
auto 1 = 3;
auto j = 4;
 
ClipSpy results:
 
CF_UNICODETEXT
00000000  61 00 75 00  74 00 6F 00  a.u.t.o.
00000008  20 00 31 00  20 00 3D 00   .1. .=.
00000010  20 00 33 00  3B 00 0D 00   .3.;...
00000018  0A 00 0D 00  0A 00 61 00  ......a.
00000020  75 00 74 00  6F 00 20 00  u.t.o. .
00000028  6A 00 20 00  3D 00 20 00  j. .=. .
00000030  34 00 3B 00  0D 00 0A 00  4.;.....
00000038  0D 00 0A 00  00 00        ......
 
RichText
00000000  7B 5C 72 74  66 5C 61 6E  {\rtf\an
00000008  73 69 7B 5C  66 6F 6E 74  si{\font
00000010  74 62 6C 7B  5C 66 30 20  tbl{\f0
00000018  43 6F 6E 73  6F 6C 61 73  Consolas
00000020  3B 7D 7D 7B  5C 63 6F 6C  ;}}{\col
00000028  6F 72 74 62  6C 3B 5C 72  ortbl;\r
00000030  65 64 30 5C  67 72 65 65  ed0\gree
00000038  6E 30 5C 62  6C 75 65 32  n0\blue2
00000040  35 35 3B 5C  72 65 64 30  55;\red0
00000048  5C 67 72 65  65 6E 30 5C  \green0\
00000050  62 6C 75 65  30 3B 7D 5C  blue0;}\
00000058  66 30 20 5C  66 73 31 39  f0 \fs19
00000060  20 5C 63 66  31 20 5C 63   \cf1 \c
00000068  62 30 20 5C  68 69 67 68  b0 \high
00000070  6C 69 67 68  74 30 20 61  light0 a
00000078  75 74 6F 5C  63 66 32 20  uto\cf2
00000080  20 31 20 3D  20 33 3B 5C   1 = 3;\
00000088  70 61 72 20  5C 70 61 72  par \par
00000090  20 5C 63 66  31 20 61 75   \cf1 au
00000098  74 6F 5C 63  66 32 20 20  to\cf2 
000000A0  6A 20 3D 20  34 3B 5C 70  j = 4;\p
000000A8  61 72 20 5C  70 61 72 20  ar \par
000000B0  7D 00                     }.
 
Notepad++
auto 1 = 3;
 
 
auto j = 4;
 
 
 
 
 
ClipSpy results:
CF_UNICODETEXT
00000000  61 00 75 00  74 00 6F 00  a.u.t.o.
00000008  20 00 31 00  20 00 3D 00   .1. .=.
00000010  20 00 33 00  3B 00 0D 00   .3.;...
00000018  0A 00 0D 00  0A 00 61 00  ......a.
00000020  75 00 74 00  6F 00 20 00  u.t.o. .
00000028  6A 00 20 00  3D 00 20 00  j. .=. .
00000030  34 00 3B 00  0D 00 0A 00  4.;.....
00000038  0D 00 0A 00  00 00        ......
 
CF_TEXT
00000000  61 75 74 6F  20 31 20 3D  auto 1 =
00000008  20 33 3B 0D  0A 0D 0A 61   3;....a
00000010  75 74 6F 20  6A 20 3D 20  uto j =
00000018  34 3B 0D 0A  0D 0A 00     4;.....
 
CF__OEMTEXT
00000000  61 75 74 6F  20 31 20 3D  auto 1 =
00000008  20 33 3B 0D  0A 0D 0A 61   3;....a
00000010  75 74 6F 20  6A 20 3D 20  uto j =
00000018  34 3B 0D 0A  0D 0A 00     4;.....
 

So Visual Studio stores a CF_UNICODETEXT clip and a Rich Text Format clip on the clipboard. NotePad++ stores a CF_UNICODETEXT, a CF_TEXT, and a CF_OEMTEXT clip on the clipboard. The crux here is which ones and in what order Evernote chooses when a paste operation is performed. First things: The CF_UNICODETEXT generated by both VS and NP++ appear to be identical, so that's likely not the cause of the difference, since when getting clipboard data, you access data by format (for example, in the software I work on, we ask first for CF_TEXT, then CF_OEMTEXT, then CF_UNICODETEXT) when retrieving text from the clipboard; first one wins. If CF_UNICODETEXT was requested first by Evernote, then the handling should be identical. Another thing: Evernote is a rich text environment, so it's not unlikely that it would ask for rich text formats first (Rich Text Format and HTML Format would seem to be likely candidates), so perhaps the bad behavior with pasting from VS stems from that. Maybe it's collapsing the consecutive '\par' markup into a single line feed; I'm not sure. Given that, it's still not possible to say which of the CF_UNICODETEXT or the CF_TEXT clips (the CF_TEXT and CF_OEMTEXT from NP++ appear to be identical) that's causing the problem on NP++ clips. 

Figuring out what Evernote is doing specifically is probably more work than I care to take on at the moment.

Link to comment
17 hours ago, jefito said:

so it's not unlikely that it would ask for rich text formats first

If I remember correctly, HTML is the first format requested (well, actually the 2nd, the 1st is EN's special format). Then RTF, followed by UNICODE. Somewhere in there is bitmaps...

  • Like 1
Link to comment
  • Level 5*
28 minutes ago, dcon said:

If I remember correctly, HTML is the first format requested (well, actually the 2nd, the 1st is EN's special format). Then RTF, followed by UNICODE. Somewhere in there is bitmaps...

Thanks, seems to accord, more or less, with my half-intelligent guesses. The real mystery, of course, is how these get turned into HTML (assuming that that's what is fed into the CEF) once the clip gets into in Evernote's clutches. It does seem like something's awry.

Link to comment

Btw, I tried messing around with the HTML content in clipboard, and I couldn't find any combination of divs, p's, evernote clipboard attributes, actual newlines, brs, etc. that would result in the desired outcome.

I didn't play with the richtext since that format is more foreign to me. But, if you say that the richtext could work, it could be worth for me to try building a utility that will convert CF_(UNICODE/OEM)TEXT to the required richtext data inside the clipboard to be able to paste it correctly... This is still pretty annoying though.

This would mean that the RichText is the *only* thing that'd work, though. Even EN's own format doesn't work! You can see this by simply copying and pasting such a piece of code from Evernote to itself... Just select it and press Ctrl+C, Ctrl+V. It will also double the newlines...

Link to comment
On 2/19/2020 at 12:10 AM, Dave-in-Decatur said:

I know less than zip about code blocks. But I see the Web beta editor (https://www.evernote.com/client/web) has code blocks. Do they also have this problem there?

Hi, I tried to paste the same code into the code block web editor and it works OK. No double lines! And when the synchronisation is done with my Windows evernote client, it doesn't double lines. The thing is I never use the web editor but it is a first workaround if I need to paste some important code block. Thanks!

Link to comment

@jefito Hm I was a bit fast in concluding that the rich text format would work.

I tested it now with Visual Studio as well, and I can see it then instead removed the empty lines. (Actually, we can see that even in your post.)

So we have the option to either get twice as many empty lines as needed or none at all. Both options are not really usable. 💔

Link to comment
On 2/28/2020 at 12:22 PM, CherryDT said:

@jefito Hm I was a bit fast in concluding that the rich text format would work.

I tested it now with Visual Studio as well, and I can see it then instead removed the empty lines. (Actually, we can see that even in your post.)

So we have the option to either get twice as many empty lines as needed or none at all. Both options are not really usable. 💔

Yes I just tested it in Microsoft Word and it is having the same behavior... Too bad because the code block used to work pretty well and was very usefull in earlier release. 

Please EN developer team, take this matter seriously. Thanks!

Link to comment

I have a workaround now. I hope it can help others as well.

I wrote a script that converts the plain text in the clipboard to HTML that is accepted by Evernote as a code block. You can then easily paste the code without messing up formatting.

If you paste it outside a code block, you will get a code block with your code inside.

If you paste it inside an existing block, you will also get the code pasted correctly, however it will insert one extra line break before it. You have to remove it manually.

  1. Install AutoHotkey
  2. Download the WinClip library
  3. Get my script
  4. Place evernote_code_wrap.ahk (my script), WinClip.ahk and WinClipAPI.ahk (from the WinClip library) next to each other in a folder
  5. Run evernote_code_wrap.ahk

Now, you can press Ctrl+Alt+V to convert and paste. (There is also Ctrl+Alt+P to just convert inside the clipboard without immediately pasting.)

You can set up AutoHotkey to load the script automatically when you start your computer.

  • Like 1
Link to comment
  • 2 weeks later...
Changing the content of the clipboard before copying is actually the most effective hack to solve the problem, a complicated task in itself but very simple with AutoHotKey which shines in this area.
 
This simple "Ctrl Alt V" is the best workaround I have found, thanks for posting.
Link to comment
On 2/28/2020 at 1:58 PM, CherryDT said:

I have a workaround now. I hope it can help others as well.

I wrote a script that converts the plain text in the clipboard to HTML that is accepted by Evernote as a code block. You can then easily paste the code without messing up formatting.

If you paste it outside a code block, you will get a code block with your code inside.

If you paste it inside an existing block, you will also get the code pasted correctly, however it will insert one extra line break before it. You have to remove it manually.

  1. Install AutoHotkey
  2. Download the WinClip library
  3. Get my script
  4. Place evernote_code_wrap.ahk (my script), WinClip.ahk and WinClipAPI.ahk (from the WinClip library) next to each other in a folder
  5. Run evernote_code_wrap.ahk

Now, you can press Ctrl+Alt+V to convert and paste. (There is also Ctrl+Alt+P to just convert inside the clipboard without immediately pasting.)

You can set up AutoHotkey to load the script automatically when you start your computer.

Works perfectly as needed thanks so much. I don't really like to depend on anything other than a software's native features but I have to admit that this helps a lot in this case! Good job. I don't really know how it works but it works. :)

Link to comment
  • 2 months later...
  • 3 weeks later...

Can you please do the following to help me debug the problem:

  1. Download InsideClipboard from here
  2. Copy the source text
  3. Open InsideClipboard, select the displayed entries one by one and create a screenshot of each
  4. Use my script to convert the text (Ctrl+Alt+P)
  5. Refresh InsideClipboard, again select the displayed entries one by one and create a screenshot of each
  6. Post the screenshots here

Thank you

Link to comment
  • 1 month later...
  • Level 5*
58 minutes ago, Pozinux said:

EN, any work on this issue please? It used to work properly, why it doesn't anymore?! Please correct this bug, it should be easy to solve! 

This is a -mainly- user-supported Forum. As users, we can offer information and suggestions from our collective experience. Although Evernote staffers do read the posts here, and there are Admins to keep everyone in line, there's no guarantee how soon your post will be seen.  Evernote tend not to comment on when or whether any given bug might be cleared or when features will be added.

Link to comment

I know thanks but, it kind of add steps that are unecessary if the native feature would work properly. It is like if you had to use another software or script to be able to format a word in bold in Word... It would work but it is pretty anoying having to do that. 

Link to comment
8 minutes ago, CherryDT said:

Ah, yes of course I totally agree. I just thought for a moment that you sounded frustrated because you didn't have a solution. 

I'm so frustrated but thanks to you not because I don't have solution. 😊

Link to comment
  • 3 weeks later...
On 2/28/2020 at 6:58 AM, CherryDT said:

I have a workaround now. I hope it can help others as well.

I wrote a script that converts the plain text in the clipboard to HTML that is accepted by Evernote as a code block. You can then easily paste the code without messing up formatting.

If you paste it outside a code block, you will get a code block with your code inside.

If you paste it inside an existing block, you will also get the code pasted correctly, however it will insert one extra line break before it. You have to remove it manually.

  1. Install AutoHotkey
  2. Download the WinClip library
  3. Get my script
  4. Place evernote_code_wrap.ahk (my script), WinClip.ahk and WinClipAPI.ahk (from the WinClip library) next to each other in a folder
  5. Run evernote_code_wrap.ahk

Now, you can press Ctrl+Alt+V to convert and paste. (There is also Ctrl+Alt+P to just convert inside the clipboard without immediately pasting.)

You can set up AutoHotkey to load the script automatically when you start your computer.

I used the idea from CherryDT to create a bash script that will work for users of macOS.

https://gist.github.com/RichardBronosky/c2d609b721df3ecc771c4980e9f6b63f

But it does little to fix the frustration that comes from even needing such a workaround.

Link to comment
  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...