Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarlevin committed Jul 6, 2024
1 parent 6462d0f commit c30fe14
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
"markdownDescription": "Select which method to use when viewing the output of a pretext project. Leaving this at the default will ask for available methods each time. Your choice will likely depend on the size of your project and whether you are building output other than the 'web' target."
},
"pretext-tools.formatter.blankLines": {
"type":"string",
"type": "string",
"default": "some",
"enum": [
"few",
Expand Down Expand Up @@ -304,4 +304,4 @@
"prettier": {
"tabWidth": 2
}
}
}
20 changes: 10 additions & 10 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ export async function activate(context: vscode.ExtensionContext) {
"log"
);

// set up status bar item
// set up status bar item
ptxSBItem = vscode.window.createStatusBarItem(
vscode.StatusBarAlignment.Left,
Expand All @@ -212,15 +211,16 @@ export async function activate(context: vscode.ExtensionContext) {
let ptxInstalled = utils.ptxExec !== "";
console.log("Pretext is installed is:", ptxInstalled);


var targetSelection = utils.getTargets();
console.log("targetSelection is:", targetSelection);
lastTarget = targetSelection[0].label;
pretextCommandList[0].label = "Build " + lastTarget;
console.log(
"Targets are now:" +
targetSelection.map(function (obj) {
return " " + obj.label;
})
targetSelection.map(function (obj) {
return " " + obj.label;
})
);

///////////////// Formatter //////////////////////
Expand Down Expand Up @@ -502,15 +502,15 @@ export async function activate(context: vscode.ExtensionContext) {
targetSelection = utils.getTargets();
console.log(
"Targets are now:" +
targetSelection.map(function (obj) {
return " " + obj.label;
})
targetSelection.map(function (obj) {
return " " + obj.label;
})
);
vscode.window.showInformationMessage(
"Refreshed list of targets. Targets are now:" +
targetSelection.map(function (obj) {
return " " + obj.label;
})
targetSelection.map(function (obj) {
return " " + obj.label;
})
);
})
);
Expand Down
6 changes: 3 additions & 3 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export function formatPTX(document: vscode.TextDocument): vscode.TextEdit[] {
let startTag = new RegExp("<" + tag + "(.*?)>", "g");
let endTag = new RegExp("<\\/" + tag + ">(.?)", "g");
let selfCloseTag = new RegExp("<" + tag + "(.*?)/>", "g");
allText = allText.replace(startTag, "\n$&");
allText = allText.replace(startTag, "\n$&");
allText = allText.replace(endTag, "$&\n");
allText = allText.replace(selfCloseTag, "$&\n");
}
Expand Down Expand Up @@ -293,7 +293,7 @@ export function formatPTX(document: vscode.TextDocument): vscode.TextEdit[] {
continue;
} else if (trimmedLine.startsWith("<?")) {
// It's the start line of the file:
fixedLines.push(trimmedLine+"\n");
fixedLines.push(trimmedLine + "\n");
} else if (trimmedLine.startsWith("<!--")) {
// It's a comment:
fixedLines.push(indentChar.repeat(level) + trimmedLine);
Expand Down Expand Up @@ -345,7 +345,7 @@ export function formatPTX(document: vscode.TextDocument): vscode.TextEdit[] {
break;
case "many":
for (let i = 0; i < fixedLines.length - 1; i++) {
if (fixedLines[i].trim().startsWith("</") || (fixedLines[i].trim().startsWith("<") && fixedLines[i+1].trim().startsWith("<"))) {
if (fixedLines[i].trim().startsWith("</") || (fixedLines[i].trim().startsWith("<") && fixedLines[i + 1].trim().startsWith("<"))) {
fixedLines[i] += "\n";
}
}
Expand Down

0 comments on commit c30fe14

Please sign in to comment.