Skip to content

Commit

Permalink
feat: keep appended newlines in-place when sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
1nVitr0 committed Aug 22, 2022
1 parent ad61164 commit 312229b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,12 @@
"description": "Regex for incomplete blocks. `^` and `$` will be expanded to allow comments",
"scope": "language-overridable",
"default": "(if|when|else|case|for|foreach|else|elsif|while|def|then|default)\\s*('([^']|(?<=\\\\)')*'|\"([^\"]|(?<=\\\\)\")*\"|`([^`]|(?<=\\\\)`)*`|[A-Za-z_+\\-*/%<>d.,s]*)*\\s*(.*:)?$"
},
"blocksort.keepAppendedNewlines": {
"type": "boolean",
"description": "Keep appsended newlines when sorting blocks",
"scope": "language-overridable",
"default": true
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/providers/ConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ export default class ConfigurationProvider {
};
}

public static getKeepAppendedNewlines(): boolean {
return ConfigurationProvider.getConfiguration().keepAppendedNewlines;
}

public static getEnableNaturalSorting(): boolean {
return ConfigurationProvider.getConfiguration().enableNaturalSorting;
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/StringProcessingProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default class StringProcessingProvider {
}

public isIndentIgnoreLine(line: string | LineMeta, document: TextDocument): boolean {
if (typeof line != "string") return line.ignoreIndent;
if (typeof line != "string") return line.ignoreIndent || !line.hasContent;

const indentIgnoreMarkers = ConfigurationProvider.getIndentIgnoreMarkers(document);
const comment = commentRegex[this.document.languageId || "default"] || commentRegex.default;
Expand Down

0 comments on commit 312229b

Please sign in to comment.