qcz / vscode-text-power-tools

Text Power Tools extension for VS Code
https://marketplace.visualstudio.com/items?itemName=qcz.text-power-tools
MIT License
96 stars 14 forks source link

Keep only unique lines is deleting all lines with duplicates #76

Open daniel-barrows opened 1 year ago

daniel-barrows commented 1 year ago

Description

The function: "Keep only unique lines" should detect lines which have duplicates, and keep only one copy of the line, which previously had 2 or more copies. However, the function is deleting all lines with duplicates

Steps to reproduce

  1. In any document, enter the following text:

    a a  

  2. Select the lines including both lines containing "a". It doesn't matter if leading or trailing newlines are included in the selection.

  3. Open the Command Palette

  4. Execute the command "Text Power Tools: Keep only unique lines"

What happens

The entire selection is deleted.

What I expected to happen

The selection is replaced with a single line containing "a"

Variations

I have similar results with multiple distinct duplicate lines, (A A B B =>),
or with duplicate lines between non-duplicate lines (A B B C => A C).

Environment

Recommendations

You may want to look into using the code from bibhasdn's Unique Lines extension. I've been using it for years without problems and it has always worked well, but I had thought Text Power Tools made it redundant.

h0jeZvgoxFepBQ2C commented 1 year ago

Yeah this is pretty confusing, but actually what the command says "keep only lines which are unique" and not "remove duplicates"... There should really be another option to filter out the duplicates? I mean VSCode offers something like this, like "Delete Duplicate lines".

Bildschirmfoto 2023-10-27 um 12 53 14

But yeah, I also think "keep only unqiue lines" should be renamed to something better, coming from sublime this command behaves really different.

spachner commented 4 weeks ago

Yes, same here. Was expecting same as linux tool 'uniq' is doing. Confusing