Skip to content

Commit

Permalink
fix: script stop after one selector
Browse files Browse the repository at this point in the history
  • Loading branch information
enzo-mourany committed Jan 17, 2023
1 parent 4c84a65 commit a6460fa
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export const sortProperties = () => {
let sortedLines: string[] = [];

let i: number = 0;
for (let line of lines) {
//for (let line of lines) {
while (i < lines.length) {
let line: string = lines[i];
// Check if the line is a CSS selector
if (line.trim().endsWith('{')) {
let selector: string = line.trim();
Expand Down Expand Up @@ -49,13 +51,19 @@ export const sortProperties = () => {
sortedLines.push(prop);

// Replace the text within the active text editor with the sorted lines
/*
editor.edit(editBuilder => {
editBuilder.replace(new vscode.Range(start.line, start.character, end.line, end.character), selector + '\n' + properties.join('\n') + '\n}');
});
*/
}
sortedLines.push('}');
if(lines[i + 1] && lines[i + 1].trim() !== '}'){
sortedLines.push('}');
}
i++;
} else {
sortedLines.push(line);
i++;
}
}

Expand Down

0 comments on commit a6460fa

Please sign in to comment.