Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export const sortProperties = (): void => {
let i: number = 0;
let workspaceIndentation = vscode.workspace.getConfiguration('editor').get('tabSize') as number;

// Comments management
let comments: {
includes(arg0: string): unknown; line: number, text: string
}[] = [];

while (i < lines.length) {
let line: string = lines[i];

Expand Down Expand Up @@ -68,11 +73,17 @@ export const sortProperties = (): void => {
sortedLines.push(`${selectorIndent}${selector}`);
}


// Add the properties to the sortedLines array
for (let prop of properties) {
if (!prop.endsWith(';')) {
prop += ';';
}
let commentIndex = comments.findIndex(c => c.line === i + 1);
if (commentIndex !== -1) {
sortedLines.push(comments[commentIndex].text);
comments.splice(commentIndex, 1);
}
sortedLines.push(indentation + prop);
}
if(lines[i + 1] && lines[i + 1].trim() !== '}') {
Expand Down