Skip to content

Commit

Permalink
Secure previous changes to onType (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
mborik committed Dec 9, 2021
1 parent 8c87703 commit 7949960
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/formatProcessor.ts
Expand Up @@ -185,7 +185,7 @@ export class FormatProcessor extends ConfigPropsProvider {
text = text.replace(fullMatch, '').trim();
}

const trimmedText = text.trimStart();
const trimmedText = isOnType ? text.trimStart() : text.trim();
const moduleLineMatch = regex.moduleLine.exec(trimmedText);
const macroLineMatch = regex.macroLine.exec(trimmedText);
const controlKeywordMatch = regex.controlKeywordLine.exec(trimmedText);
Expand Down Expand Up @@ -229,7 +229,7 @@ export class FormatProcessor extends ConfigPropsProvider {
indentLevel = configProps.baseIndent;
}

if (configProps.splitInstructionsByColon && text.includes(':')) {
if (configProps.splitInstructionsByColon && !isOnType && text.includes(':')) {
const splitLine = this._safeSplitStringByChar(text, ':');
if (splitLine.length > 1) {
lineParts.fragments = splitLine.map(
Expand All @@ -239,7 +239,8 @@ export class FormatProcessor extends ConfigPropsProvider {
}

if (!lineParts.fragments) {
const { keyword, args } = this._processFragment(text.trimStart());
const trimmedText = isOnType ? text.trimStart() : text.trim();
const { keyword, args } = this._processFragment(trimmedText);
lineParts.keyword = keyword;
lineParts.args = args;
}
Expand Down

0 comments on commit 7949960

Please sign in to comment.