-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pasting long block from clipboard inserts wrong content for line breaks #4562
Comments
pasting as it should be: |
paste as it happens with inserted nonsense: |
I can't reproduce your problem on macOS with Apple Terminal.
In as far as I'm concerned, it looks like it's the terminal emulation application you are using that is cutting the text that is being given to mc, whereas mc itself is able to deal with any large blocks of text that are given to it.
Try a different terminal application (xterm, urxvt, ...). |
[ solved ]
file in
with content like:
after removing it mc / mcedit works as expected. |
Replying to zaytsev:
hello @ zaytsev,
best regards,
newbie-02 |
You probably inadvertently triggered the "record macro" feature and then pasted something that got recorded as a macro. |
hmmmmmmmmm ...
yes and no, I somtimes use Ctrl-r to re-read directory contents, when in editor that triggers macro recording, can imagine having made a mistake there. |
|
Please don't reopen unless you have a reproducer. As I said, my working assumption is that you accidentally pressed CTRL+R in the editor at some point and the pasted your stuff which got recorded as a huge macro, so there is nothing to fix here. |
hello @ zaytsev,
produces a copy of the file as expected.
produces a file like the attached 'mc_paste_test02.txt', which has some injected parts
think that isn't wanted? |
Testfile which changes in pasting, |
File changed in pasting |
This is the only thing that matters though.
With the macro that's to be expected. |
no, it's not. notably, the editor already contains code that suppresses auto-indentation on pasted text. it obviously should suppress macro expansion as well. |
Maybe I'm thinking too simple there, which is always an option, but if I want to paste something, I usually want to paste >that<, not changes.
@ zaytsev:
don't think so, consider it an accident in typing, but should somehow be communicated and / or accessible to the user that he now has a macro and in which situations it will strike.
can I find somewhere which type / content of macro would take which action in which situation? All I found yet was how to record, assign a key and run. Nothing about any automated action and how to design for that.
@ ossi: |
Well, detecting pasting is not possible reliably in a general way. We might try to use paste mode, if the terminal supports it, but I'm not sure whether we do have any code in the editor right now for that. If you're saying there is something there to suppress autoindent, then it can be extended to support macros, if it doesn't do this already. If you want to make a patch, we might try to take it in. |
Am I right in understanding that there is something like 'automatic macro expansion' which in mc's internal editor automatically executes a replacement of the character assigned as macro start character by the steps defined for the macro?
in mc.macros will replace every typed 'u' by a 'X' and 'x' by 'U'?
Workaround tip for others affected: avoid macros or use another editor. |
yes, the macro functionality is extremely aggressive. while it can be very convenient to assign shortcuts like ctrl-a (though the really interesting ones like ctrl-f1 don't seem to work), it seems a tad over the top that printable characters can be mapped as well.
note that the text from your webpage testcase actually contains markup; you can verify that by pasting it into libreoffice. apparently, your terminal interprets this by inserting kpenter (whatever that might be) into the stream. |
short:
IMHO defining macros as something the user can activate by a special typed! key sequence ( Ctrl-A and the assigned start character ) and then evaluating it at totally different situations ( pasting ) and in a totally different way ( replace the assigned character on its own ) is 'questionable'.
Evtl. it could also be meaningful to have different definitions for macros vs. automatic replacements?
Don't know which one is selected or how it can be steered which to paste by Ctrl-Shift-V. But simple character replacement in mc hits on any version. |
kpenter is "Keypad Enter" |
yes. from my side the question was what the actual meaning/code is in a terminal, as i couldn't produce it in konsole without doing research first.
xclip can be used by mc; it's just a mess and requires configuration (see #4458 & #3083). |
hmmmmm ... |
index 56d381df2..8f5fe8bfe 100644
--- a/src/editor/editwidget.c
+++ b/src/editor/editwidget.c
@@ -959,7 +959,7 @@ edit_callback (Widget *w, Widget *sender, widget_msg_t msg, int parm, void *data
cb_ret_t ret = MSG_NOT_HANDLED;
/* The user may override the access-keys for the menu bar. */
- if (macro_index == -1 && edit_execute_macro (e, parm))
+ if (macro_index == -1 && !bracketed_pasting_in_progress && edit_execute_macro (e, parm))
{
edit_update_screen (e);
ret = MSG_HANDLED; |
Do you want to commit? I approve. |
Branch: 4562_mcedit_macros_paste |
|
|
|
Important
This issue was migrated from Trac:
newbie-02
(newbie-02@….de)paste
,wrong
,content
hi @ all, I'm new here, sorry for all I might do wrong,
short description: pasting a long block from a web-browser inserts one special block of 'foreign content' after / instead of multiple line breaks, making result unusable.
I'm aware it's a weird problem, did all I can do, persistent, thus ask for help, if not solvable already info if 'clean or bad on other systems' or hints for further track down can be helpful.
After I first noticed I tried lots of things, none helped, just now installed mc from scratch, issue persists.
System: actual Kali linux ( Debian ) on Intel ( Xeon ) hardware which works quite stable.
Reproducibility: copy some text from a webpage, as reference I marked the main text of https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ from 'Comparing Floating Point Numbers, 2012 Edition' to 'with all of its flaws' in actual version of Brave and copied by Ctrl-C.
If I paste into a text application, e.g. 'Mousepad', by Ctrl-V I get a meaningful display and can save the text.
Opening an empty text file with mc ( F4 ) and pasting there with Shift-Ctrl-V the pasting takes some time, with cursor flipping around on the screen, and then I get the start of the page as wanted, but starting at some point a special block of nonsense is inserted instead of most ( all? ) linebreaks. The point where the nonsense starts varies from try to try.
I'll try to attach the head of a copy from pasting into Mousepad and alternately mc.
The problem is persistent, the block is always the same, and behavior didn't change with fresh installation of mc ( ver. 4.8.31 from today - git clone https://github.com/MidnightCommander/mc.git - ./autogen.sh - sudo apt install build-dep mc ( S-Lang was missing ) - ./configure - make -j12 - sudo make install -j12 ).
As the unwanted block is part of another text on my system I think me or my system bad, as it's always the same I think must be configured / referenced somewhere, but couldn't find that block in all my files ( searched all files inc. configuration and hidden ) except in the origin and where I saved pasting tries with mc.
Even tried to work on another disk ( home instead of data ), same problem, same block.
Have been involved in two other pasting bugs, LO Calc sometimes not pasting content from other apps, was a windows 'occupied, wait and retry' problem, and GNOME Gnumeric not pasting webbrowser content, was a 'browser exports bad html' problem, IMHO none of them fits here.
Trying a workaround which there often helped, paste into pure text application, copy from there and then paste into mc doesn't work here, produces same / similar wrong content.
I'm clueless, can anybody give a hint?
To make it a good bug report, info as requested:
'search before create new ticket' - I searched 'paste' and 'wrong', 2 pages of reports, none matching my experience,
LC_MESSAGES=C mc -V:
GNU Midnight Commander 4.8.31
Built with GLib 2.78.4
Built with S-Lang 2.3.3 with terminfo database
Built with libssh2 1.11.0
With builtin Editor and Aspell support
With subshell support as default
With support for background operations
With mouse support on xterm and Linux console
With support for X11 events
With internationalization support
With multiple codepages support
With ext2fs attributes support
Virtual File Systems:
Data types:
LC_MESSAGES=C mc -F:
Home directory: /home/kali
Profile root directory: /home/kali
[System data]
[User data]
mc --configure-options:
search: did, see above,
distribution first: did fresh compile from sources,
steps: see head of this report,
expected: file like attached 'mc_paste_should.txt', note that that's only the first few paragraphs!
see instead: file like attached 'mc_paste_happening.txt', note that that's only the first few paragraphs! The issue strikes in long pasting only!
Note
Original attachments:
newbie-02
(newbie-02@….de) onJul 17, 2024 at 20:34 UTC
newbie-02
(newbie-02@….de) onJul 17, 2024 at 20:35 UTC
newbie-02
(newbie-02@….de) onJul 18, 2024 at 19:34 UTC
newbie-02
(newbie-02@….de) onJul 18, 2024 at 19:35 UTC
newbie-02
(newbie-02@….de) onJul 18, 2024 at 19:36 UTC
The text was updated successfully, but these errors were encountered: