Skip to content

Sorting line does not properly sort quoted strings #199033

@sroucheray

Description

@sroucheray

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.84.2
  • OS Version: Linux x64 5.14.0-1054-oem

Steps to Reproduce:

  1. Open an SCSS file with the following content:
@import 'file-a-aaa';
@import 'file-a';
@import 'file-a-ccc';
@import 'file-a-bbb';
  1. select all lines
  2. CTRL+P then trigger "Sort line ascending"

Result:

@import 'file-a-aaa';
@import 'file-a-bbb';
@import 'file-a-ccc';
@import 'file-a';

NB: last line is position here because in the sort algorithm of Int.Collator the character - (e.g. line 3: @import 'file-a- <-- this one) comes before the character '.

Expected result:

@import 'file-a';
@import 'file-a-aaa';
@import 'file-a-bbb';
@import 'file-a-ccc';

NB: it feels more "natural" to me to have @import 'file-a'; on the first line when sorting. For this we might ignore punctuation when sorting by explicitly setting it here

SortLinesCommand._COLLATOR = new Intl.Collator(undefined, { ignorePunctuation: true });

I see two ways to fix the problem:

  1. Hard ignoring punctuation considering it is a better default
  2. Introduce a new setting for line sorting: ignorePunctuation : true | false (default) to keep current behavior but make it possible to change it

Metadata

Metadata

Assignees

Labels

*duplicateIssue identified as a duplicate of another issue(s)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions