duydao / Text-Pastry

Extend the power of multiple selections in Sublime Text. Modify selections, insert numeric sequences, incremental numbers, generate uuids, date ranges, insert continuously from a word list and more.
MIT License
830 stars 46 forks source link

Issues working with Improved paste (paste the first three lines of the clipboard data to the three selected locations) #89

Closed stdedos closed 3 years ago

stdedos commented 3 years ago

As per README.md:

Improved paste (paste the first three lines of the clipboard data to the three selected locations)

and, I guess it's the same as:

Paste as Block

I think it used to be working, but now I cannot get it to work.

The intention is to copy this:


      <param name="a">b</param>

to go from this:

      <param name="1">2</param>

      <param name="3">4</param>

to this:

      <param name="1">2</param>
      <param name="a">b</param>

      <param name="3">4</param>
      <param name="a">b</param>

However, none of the commands:

can get me to the desired result cleanly.

After all of the above, the closest I get is this:

      <param name="1">2</param>
<param name="a">b</param>

      <param name="3">4</param>
<param name="a">b</param>

I was wondering if you could help, expand documentation, and/or fix a behavior if it's problematic.

duydao commented 3 years ago

Hi!

thanks for using Text Pastry!

Paste as block should take every line of the clipboard and treats it as a queue. If we copy a block like this

first line
second line
third line

and paste it into this selection

<a>|</a>
<b>|</b>
<i>|</i>

we would get this:

<a>first line</a>
<b>second line</b>
<i>third line</i>

instead of this:

<a>first line
second line
third line</a>
<b>first line
second line
third line</b>
<i>first line
second line
third line</i>

may I ask you for a different example of your use-case?

stdedos commented 3 years ago

Perhaps I haven't been clear enough, apologies. I am not that familiar with the finer details of the plugin.

I want to use TextPastry's feature that will help me treat the copied text "as one entity", instead of splitting it as newlines.

i.e. If I copy 2 lines and have 2 carets, I expect to paste 2 lines on both carets, instead of one each.

duydao commented 3 years ago

Thanks for taking your time to clarify this issue.

This should already be a default feature of sublime text!

Expanding on your example, if we copy this line into the clipboard:

      <param name="a">b</param>

we can paste it normally and it will be inserted on every location with a caret, as this clip shows:

paste

Would that the feature, that you were looking for?

stdedos commented 3 years ago

Thank you for your quick response. Please note that my example is not this:

      <param name="a">b</param>

but it's that:


      <param name="a">b</param>

(i.e. one extra \n)

duydao commented 3 years ago

Thank you for clarifying the issue!

The content shouldn't matter, as long as we paste using the default paste (ctrl+v or cmd+v), the text will be pasted into the selected location by sublime text, as shown in this clip:

paste2

Please let me know if we're on the right track on this issue!

stdedos commented 3 years ago

Again, you are making a different selection 😂


      <param name="a">b</param>

vs


      <param name="a">b</param>
duydao commented 3 years ago

Ah, your example does does not select the new line character at the end.

This is a "feature"/bug in sublime text and it only happens, when the selection count matches the pasted content split by newline. If I would've select three instances of the </param> endtag, instead of two, it would behave oddly aswell. Even when I've disable/uninstall Text Pastry, we would still have this behaviour (please feel free to confirm this behaviour).

It works in my example because I was selecting an additional newline, which made the number of carets mismatch with the pasted content. This would also be the workaround: it should work if we paste the content into more selections/carets. Maybee there is a bugfix in the latest version of Sublime Text, that would be worth a shot.

I've checked the sources of text pastry, and unfortunately we don't have an option to paste "as is" atm. option. I will check the conditions to add such a feature.

Thanks for using text pastry!