handle def file formatter
This commit is contained in:
@@ -12,10 +12,29 @@ export function formatCdlFile(content: string): string {
|
||||
if (strippedLine.endsWith("{")) {
|
||||
indentLevel += 1
|
||||
}
|
||||
if (strippedLine.startsWith("#")) {
|
||||
formattedLines[formattedLines.length - 1] =
|
||||
" ".repeat(indentLevel) + strippedLine.replace(/^#\s*/, "# ")
|
||||
}
|
||||
}
|
||||
return formattedLines.join("\n")
|
||||
}
|
||||
|
||||
export function formatDefFile(content: string): string {
|
||||
let indentLevel = 0
|
||||
const formattedLines = []
|
||||
for (const line of content.split("\n")) {
|
||||
const strippedLine = line.trim()
|
||||
if (strippedLine.endsWith("}")) {
|
||||
indentLevel = Math.max(indentLevel - 1, 0)
|
||||
}
|
||||
formattedLines.push(" ".repeat(indentLevel) + strippedLine)
|
||||
if (strippedLine.endsWith("{")) {
|
||||
indentLevel += 1
|
||||
}
|
||||
}
|
||||
return formattedLines.join("\n")
|
||||
}
|
||||
export function completionHandlerCdl(document: vscode.TextDocument, position: vscode.Position) {
|
||||
const linePrefix = document.lineAt(position).text.substring(0, position.character)
|
||||
const categories = ["MILL", "LATHE", "DRILL"]
|
||||
|
||||
Reference in New Issue
Block a user