Skip to content
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

[BUG] Copied lines are inserted in the wrong order #15151

Open
1 task done
juze92 opened this issue May 17, 2024 · 9 comments · May be fixed by #15261
Open
1 task done

[BUG] Copied lines are inserted in the wrong order #15151

juze92 opened this issue May 17, 2024 · 9 comments · May be fixed by #15261

Comments

@juze92
Copy link

juze92 commented May 17, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Description of the Issue

I want to copy/paste a rectangular selection of columns and lines (with 'alt' key) and insert this selection after an existing text into the same number of lines. I want to preserve the table layout. This worked well in the past but is not functioning any more.

Problems:

  • The two whitespaces are not considered
  • The line order is inverted WHEN I copy/paste more than 5 lines. When only working with four lines, only the whitespaces are not preserved!

The problems occur with version 8.6.7, 8.6.6, 8.6.4.
Version 8.5 works fine (I use this version until a fix of the problem).

Steps To Reproduce

E.g.: I want to add the content of the initial situation a second time, in the same lines and with two whitespaces in between.

Initial situation:

abc
def
ghi
jkl
mno
pqr
  1. I first select all rows and columns by pressing the 'alt' key to have a 6x3 rectangular selection (see image 1 in the comments).
  2. I copy the selection.
  3. After that, I want to insert the copied content (in the same lines and with two white spaces in between) by using the 'alt' key function (see image 2).
  4. After marking the lines, I paste the copied content. The expected and obtained results are below.

Current Behavior

Want I get:

  • When working with more than 4 lines:
abcpqr
defmno
ghijkl
jklghi
mnodef
pqrabc
  • When working with up to 4 lines:
abcabc
defdef
ghighi
jkljkl

Expected Behavior

What I want:

abc  abc
def  def
ghi  ghi
jkl  jkl
mno  mno
pqr  pqr

Debug Information

Notepad++ v8.6.7   (64-bit)
Build time : May 12 2024 - 20:04:00
Path : C:\Program Files\Notepad++\notepad++.exe
Command Line : "C:\Program Files\Notepad++\change.log" 
Admin mode : OFF
Local Conf mode : OFF
Cloud Config : OFF
Periodic Backup : ON
OS Name : Windows 10 Pro (64-bit)
OS Version : 22H2
OS Build : 19045.4412
Current ANSI codepage : 1252
Plugins : 
    mimeTools (3.1)
    NppConverter (4.6)
    NppExport (0.4)

Anything else?

No response

@alankilborn
Copy link
Contributor

alankilborn commented May 17, 2024

I don't doubt you are seeing a definite bug here...

However, I can't reproduce this in 8.6.7 following the steps-to-reproduce.
But, the steps are too vague because there are things implied/missing.
Please add more exacting steps to your issue.

When I try to reproduce (using guesswork because I don't know what you are doing with every action), I get:

abc  abc
def  def
ghi  ghi
jkl  jkl
mno  mno
pqr  pqr

@alankilborn
Copy link
Contributor

Just a wild guess, but could this possibly be related to #15139 , which is explained in much greater detail?

@juze92
Copy link
Author

juze92 commented May 17, 2024

Yes, I assume that. He is explaining similar things. I will add detailed explanation when I have time to do that. Thank you for your responses

@alankilborn
Copy link
Contributor

He is explaining similar things.

If it is indeed similar to what you have reported in THIS issue, you may close THIS issue and add further detail to 15139 (it's no problem adding comments to someone else's issue). Or, if you feel it is not the same, thing, feel free to keep this issue open, as long as it is your intention truly to follow up and add more here.

@juze92
Copy link
Author

juze92 commented May 18, 2024

1
2

Here are two images hopefully better explaining how to reproduce the situation.

@juze92
Copy link
Author

juze92 commented May 18, 2024

It is different to issue #15139 in that way that I do want to copy n lines and insert n lines (same number of lines). It is also not related to any tab switching.

@mpheath
Copy link
Contributor

mpheath commented May 18, 2024

Here are two images hopefully better explaining how to reproduce the situation.

@juze92 Thanks for providing the images. The 1st image shows the primary caret at the bottom of the rectangular selection. The 2nd image has the primary caret at the top of the thin selection. Might be hard to notice as I had to zoom in to see it, though the primary caret is purple and the secondary carets are black. If you paste the rectangular selection as the 2nd image shows, it will place mno at the top.

The primary caret needs to be syncronized to the same position of the top or the bottom to keep the same order. Primary caret at the top to copy and then primary caret at the top to paste will get the same order.

To make this more obvious, I have set the primary caret and primary selection background to blue and the secondary caret and secondary background to yellow. I set the caret size to 3 pixels to make it more noticable.

select1

  1. Stream selection which shows the blue colour just to display the primary caret and background.
  2. Top down rectangular selection. Note the blue is at the bottom. Copy was then done.
  3. Made a top down thin selection and then pasted the copied selection. It is in same order.
  4. Did undo and made a bottom up thin selection and then pasted the copied selection. It is in reverse order.

The consequence with the desired order of using top down or bottom up is an important detail with rectangular selections.

@Coises
Copy link
Contributor

Coises commented May 22, 2024

@juze92:

1
2

How did you reach the condition in the second image? Is the setting at Preferences | Editing 1 | Enable virtual space checked or unchecked? After you made the zero-width selection, but before you pasted, did the status bar show Sel: 6x0 = 0 or Sel 6: 0 | 6?

Recent versions of Notepad++ (following the underlying Scintilla control) have blurred the distinction between multiple selections and rectangular selections. For those of us used to using rectangular selections from when multiple selections were barely functional at all, some of the new behaviors seem incoherent. It’s tricky to keep track of what they are, because you have to look at the status bar to tell the difference between a rectangular selection and a multiple selection that just happens to line up straight.

“Thin selections” confuse matters even further; they look like zero-width rectangular selections, but they do not show the rowsxcolumns characteristic of rectangular selections. They used to behave identically to zero-width rectangular selections, but I am not sure if that is still true. There is, as far as I can tell, no way for a user to tell the difference between a thin selection and an empty multiple selection in which all the cursors line up. You just have to know the exact sequence by which you got to where you were.

In your example, I get to the same apparent position in different ways and get very different results on pasting. I do not think that should be how it works, but for now, it is. For example:

Make the rectangular selection bottom to top and copy. With virtual space enabled, use the mouse to place the caret after the c, right arrow key twice, then hold Shift+Alt and down arrow to the bottom line. Looks like second screenshot. Paste. In order top to bottom, but no space.

Make the rectangular selection bottom to top and copy. Use the mouse to place the caret after the c, type two spaces, then hold Shift+Alt and down arrow to the bottom line. Looks like second screenshot. Paste. In order top to bottom, but spaces are only in the first line.

Make the rectangular selection bottom to top and copy. Use the mouse to place the caret after the c, hold Shift+Alt and down arrow to the bottom line, type two spaces. Looks like second screenshot. Paste. In order top to bottom, two spaces in every line.

Make the rectangular selection bottom to top and copy. With virtual space enabled, use the right arrow key to move the cursor line two spaces to the right of the text. Looks like second screenshot. Paste. Comes out in reverse order, with no spaces.

I don’t like any of this, but it might be “the new normal” for Notepad++. Enhancing multiple selections has thrown consistency for rectangular selections under the bus. :-(

@Coises
Copy link
Contributor

Coises commented May 22, 2024

Related, another behavior change for rectangular selections:

Start with:

this
that and
the other thing

you
know
what I mean

(I have virtual space off, though I don’t think it matters.)

Make a rectangular selection from before this to the end of thing. Copy that.

Place the cursor after mean and use Alt+Shift+click on the line with you to make a zero-width rectangular selection, then paste.

In 8.5.8, blanks are inserted after you and know to make the pasted content line up.

In 8.6.7, the pasted content goes line by line to the end of the lines into which is was pasted, in reverse order. There are three cursors at the end of each line of the pasted content (so, different columns on each line), but the status bar still indicates a rectangular selection (Sel : 3x0 = 0). Opening a new tab and then switching back shows a rectangular selection from this to the end of thing.

I fully admit to not understanding exactly what people expect of multiple selections. But having used rectangular selections through many years of Notepad++... this behavior is unpredictable and incoherent. I can’t even figure out what all has changed, or what the “new rules” are supposed to be. It’s just... all over the place.

I should add one thing. As far as I can tell, if you select nothing — just put the caret where you want the top left of the pasted content to go and then paste — things still behave sanely. So there is a work-around: Don’t paste into rectangular selections, even zero-width ones, unless you enjoy surprises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants