[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] [PATCH] bug #48501: [Request] add the ability to paste

From: Benno Schulenberg
Subject: Re: [Nano-devel] [PATCH] bug #48501: [Request] add the ability to paste at the prompt
Date: Tue, 18 Jul 2017 20:01:52 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

Hello Rishabh,

Thanks for the patch.  That was unexpected.  :)

Op 16-07-2017 om 15:01 schreef Rishabh Dave:
Attached patch fulfills the request (see  -- user can now paste at the
prompt. I did test the patch and also checked for memory leaks too.
For me, it works as it should.

How did you test for memory leaks?  Because I found one right away,
just by looking at the code.  And valgrind confirms.  See below.

Anyway, testing the patch, I first notice that pasting only works at
the ^W prompt, not at M-R nor ^R nor ^O nor ^R ^T ^W...  It should
work at all prompts.  Further, try this:

    src/nano +7,20  README

Then type: Shift+Ctrl+Left, M-6, ^W xxxx ^U
Note how the cursor is on the "w" of "wonderfully", while it should be
at the end of the word, just as when you would have typed the word.

Press <Enter> and ^X, and check the output of valgrind:

==7602== LEAK SUMMARY:
==7602==    definitely lost: 5 bytes in 1 blocks

That is for the four exes plus one: the old answer, which wasn't freed.

When you're adjusting the patch, maybe be more creative with the names
too.  Maybe rename 'new_answer' to 'fusion'.  And I see that
'strlen(cutbuffer->data)' occurs three times; better assign that to
an intermediate variable, calling it 'pastelen' -- not for performance
but for clarity.  And it won't cost any extra lines because it will
allow you to unwrap at least one of the other lines.  And please drop
the DEBUG stuff, and make the comment precede the block of three strcpys
and describe what those three statements together do: concatenate the
head of the current answer, the first line of the cutbuffer, plus the
tail of the current answer.

But as of now nano doesn't allow newlines or tabs on prompt in any
form (at least I couldn't figure how to do it). So, only one line can
be copied at the search prompt. Do we want to paste multiple lines?

No.  There is not any prompt that allows multiple lines.  So no.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]