diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b42aa8..41d5503 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Stable +### 4.1.2: 03-Feb-2024 + +- Fixes [#139: "Position All Attributes On First Line" not work](https://github.com/pmahend1/PrettyXML/issues/139) + ### 4.1.1: 01-Feb-2024 - Fixes [#137: Apple Plist/MobileConfig files create error after first format](https://github.com/pmahend1/PrettyXML/issues/137). diff --git a/lib/XmlFormatter.CommandLine.dll b/lib/XmlFormatter.CommandLine.dll index 517a82b..8bb8de9 100644 Binary files a/lib/XmlFormatter.CommandLine.dll and b/lib/XmlFormatter.CommandLine.dll differ diff --git a/lib/XmlFormatter.CommandLine.exe b/lib/XmlFormatter.CommandLine.exe index 66942f6..98cc320 100644 Binary files a/lib/XmlFormatter.CommandLine.exe and b/lib/XmlFormatter.CommandLine.exe differ diff --git a/lib/XmlFormatter.CommandLine.pdb b/lib/XmlFormatter.CommandLine.pdb index a45a155..0a5f9a4 100644 Binary files a/lib/XmlFormatter.CommandLine.pdb and b/lib/XmlFormatter.CommandLine.pdb differ diff --git a/lib/XmlFormatter.dll b/lib/XmlFormatter.dll index b0cfe0c..7b0959d 100644 Binary files a/lib/XmlFormatter.dll and b/lib/XmlFormatter.dll differ diff --git a/lib/XmlFormatter.pdb b/lib/XmlFormatter.pdb index 354e145..952cedd 100644 Binary files a/lib/XmlFormatter.pdb and b/lib/XmlFormatter.pdb differ diff --git a/package.json b/package.json index 0ea0bd3..0b1d0ee 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ }, "readme": "https://github.com/pmahend1/PrettyXML/blob/main/README.md", "description": "XML formatter extension for Visual Studio Code. Formats XML documents just like Visual Studio.", - "version": "4.1.1", + "version": "4.1.2", "publisher": "PrateekMahendrakar", "repository": { "url": "https://github.com/pmahend1/prettyxml.git" diff --git a/src/formatter.ts b/src/formatter.ts index 4eddc90..b7c9336 100644 --- a/src/formatter.ts +++ b/src/formatter.ts @@ -1,6 +1,6 @@ import * as vscode from "vscode"; import { DocumentHelper } from "./documentHelper"; -import { DefaultSettings, Settings } from "./settings"; +import { defaultSettings, Settings } from "./settings"; import * as childProcess from "child_process"; import * as path from "path"; import { JsonInputDto } from "./jsonInputDto"; @@ -11,7 +11,7 @@ export class Formatter { private extensionContext: vscode.ExtensionContext; private dllPath: string = ""; - public settings: Settings = DefaultSettings; + public settings: Settings = defaultSettings; constructor(context: vscode.ExtensionContext) { this.extensionContext = context; this.initialize(); diff --git a/src/jsinputdto.ts b/src/jsinputdto.ts deleted file mode 100644 index ea6e8a3..0000000 --- a/src/jsinputdto.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* eslint-disable @typescript-eslint/naming-convention */ - -import { DefaultSettings } from "./settings"; - -export class JSInputDTO -{ - XMLString: string; - IndentLength: number; - UseSingleQuotes: boolean; - UseSelfClosingTags: boolean; - AllowSingleQuoteInAttributeValue: boolean; - AddSpaceBeforeSelfClosingTag: boolean; - WrapCommentTextWithSpaces: boolean; - AllowWhiteSpaceUnicodesInAttributeValues: boolean; - PositionFirstAttributeOnSameLine: boolean; - - constructor(xmlString: string, - indentLength: number = DefaultSettings.IndentLength, - useSingleQuotes: boolean = DefaultSettings.UseSingleQuotes, - useSelfClosingTags: boolean = DefaultSettings.UseSelfClosingTags, - allowSingleQuoteInAttributeValue: boolean = DefaultSettings.AllowSingleQuoteInAttributeValue, - addSpaceBeforeSelfClosingTag: boolean = DefaultSettings.AddSpaceBeforeSelfClosingTag, - wrapCommentTextWithSpaces: boolean = DefaultSettings.WrapCommentTextWithSpaces, - allowWhiteSpaceUnicodesInAttributeValues: boolean = DefaultSettings.AllowWhiteSpaceUnicodesInAttributeValues, - positionFirstAttributeOnSameLine: boolean = DefaultSettings.PositionFirstAttributeOnSameLine) - { - this.XMLString = xmlString; - this.IndentLength = indentLength; - this.UseSingleQuotes = useSingleQuotes; - this.UseSelfClosingTags = useSelfClosingTags; - this.AllowSingleQuoteInAttributeValue = allowSingleQuoteInAttributeValue; - this.AddSpaceBeforeSelfClosingTag = addSpaceBeforeSelfClosingTag; - this.WrapCommentTextWithSpaces = wrapCommentTextWithSpaces; - this.AllowWhiteSpaceUnicodesInAttributeValues = allowWhiteSpaceUnicodesInAttributeValues; - this.PositionFirstAttributeOnSameLine = positionFirstAttributeOnSameLine; - } -} diff --git a/src/settings.ts b/src/settings.ts index df96845..1c2121d 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,74 +1,70 @@ -/* eslint-disable @typescript-eslint/naming-convention */ -export interface ISettings -{ - IndentLength: number; - UseSingleQuotes: boolean; - UseSelfClosingTags: boolean; - FormatOnSave: boolean; - AllowSingleQuoteInAttributeValue: boolean; - AddSpaceBeforeSelfClosingTag: boolean; - WrapCommentTextWithSpaces: boolean; - AllowWhiteSpaceUnicodesInAttributeValues: boolean; - PositionFirstAttributeOnSameLine: boolean; - PositionAllAttributesOnFirstLine: boolean; - PreserveWhiteSpacesInComment: boolean; - EnableLogs: boolean; +export interface ISettings { + indentLength: number; + useSingleQuotes: boolean; + useSelfClosingTags: boolean; + formatOnSave: boolean; + allowSingleQuoteInAttributeValue: boolean; + addSpaceBeforeSelfClosingTag: boolean; + wrapCommentTextWithSpaces: boolean; + allowWhiteSpaceUnicodesInAttributeValues: boolean; + positionFirstAttributeOnSameLine: boolean; + positionAllAttributesOnFirstLine: boolean; + preserveWhiteSpacesInComment: boolean; + enableLogs: boolean; } -export const DefaultSettings: ISettings = { - IndentLength: 4, - UseSingleQuotes: false, - UseSelfClosingTags: true, - FormatOnSave: false, - AllowSingleQuoteInAttributeValue: true, - AddSpaceBeforeSelfClosingTag: true, - WrapCommentTextWithSpaces: true, - AllowWhiteSpaceUnicodesInAttributeValues: true, - PositionFirstAttributeOnSameLine: true, - PositionAllAttributesOnFirstLine: false, - PreserveWhiteSpacesInComment: false, - EnableLogs: false - }; +export const defaultSettings: ISettings = { + indentLength: 4, + useSingleQuotes: false, + useSelfClosingTags: true, + formatOnSave: false, + allowSingleQuoteInAttributeValue: true, + addSpaceBeforeSelfClosingTag: true, + wrapCommentTextWithSpaces: true, + allowWhiteSpaceUnicodesInAttributeValues: true, + positionFirstAttributeOnSameLine: true, + positionAllAttributesOnFirstLine: false, + preserveWhiteSpacesInComment: false, + enableLogs: false +}; -export class Settings -{ - IndentLength?: number; - UseSingleQuotes?: boolean; - UseSelfClosingTags?: boolean; - FormatOnSave?: boolean; - AllowSingleQuoteInAttributeValue?: boolean; - AddSpaceBeforeSelfClosingTag?: boolean; - WrapCommentTextWithSpaces?: boolean; - AllowWhiteSpaceUnicodesInAttributeValues?: boolean; - PositionFirstAttributeOnSameLine?: boolean; - PositionAllAttributesOnFirstLine?: boolean; - PreserveWhiteSpacesInComment?: boolean; - EnableLogs?: boolean; +export class Settings { + indentLength?: number; + useSingleQuotes?: boolean; + useSelfClosingTags?: boolean; + formatOnSave?: boolean; + allowSingleQuoteInAttributeValue?: boolean; + addSpaceBeforeSelfClosingTag?: boolean; + wrapCommentTextWithSpaces?: boolean; + allowWhiteSpaceUnicodesInAttributeValues?: boolean; + positionFirstAttributeOnSameLine?: boolean; + positionAllAttributesOnFirstLine?: boolean; + preserveWhiteSpacesInComment?: boolean; + enableLogs?: boolean; - constructor(indentLengh?: number, - useSingleQuotes?: boolean, - useSelfClosingTags?: boolean, - formatOnSave?: boolean, - allowSingleQuoteInAttributeValue?: boolean, - addSpaceBeforeSelfClosingTag?: boolean, - wrapCommentTextWithSpaces?: boolean, - allowWhiteSpaceUnicodesInAttributeValues?: boolean, - positionFirstAttributeOnSameLine?: boolean, - positionAllAttributesOnFirstLine?: boolean, - preserveWhiteSpacesInComment?: boolean, - enableLogs?: boolean) - { - this.IndentLength = indentLengh ?? DefaultSettings.IndentLength; - this.UseSingleQuotes = useSingleQuotes ?? DefaultSettings.UseSingleQuotes; - this.UseSelfClosingTags = useSelfClosingTags ?? DefaultSettings.UseSelfClosingTags; - this.FormatOnSave = formatOnSave ?? DefaultSettings.FormatOnSave; - this.AllowSingleQuoteInAttributeValue = allowSingleQuoteInAttributeValue ?? DefaultSettings.AllowSingleQuoteInAttributeValue; - this.AddSpaceBeforeSelfClosingTag = addSpaceBeforeSelfClosingTag ?? DefaultSettings.AddSpaceBeforeSelfClosingTag; - this.WrapCommentTextWithSpaces = wrapCommentTextWithSpaces ?? DefaultSettings.WrapCommentTextWithSpaces; - this.AllowWhiteSpaceUnicodesInAttributeValues = allowWhiteSpaceUnicodesInAttributeValues ?? DefaultSettings.AllowWhiteSpaceUnicodesInAttributeValues; - this.PositionFirstAttributeOnSameLine = positionFirstAttributeOnSameLine ?? DefaultSettings.PositionFirstAttributeOnSameLine; - this.PositionAllAttributesOnFirstLine = positionAllAttributesOnFirstLine ?? DefaultSettings.PositionAllAttributesOnFirstLine; - this.PreserveWhiteSpacesInComment = preserveWhiteSpacesInComment ?? DefaultSettings.PreserveWhiteSpacesInComment; - this.EnableLogs = enableLogs ?? DefaultSettings.EnableLogs; + constructor(indentLengh?: number, + useSingleQuotes?: boolean, + useSelfClosingTags?: boolean, + formatOnSave?: boolean, + allowSingleQuoteInAttributeValue?: boolean, + addSpaceBeforeSelfClosingTag?: boolean, + wrapCommentTextWithSpaces?: boolean, + allowWhiteSpaceUnicodesInAttributeValues?: boolean, + positionFirstAttributeOnSameLine?: boolean, + positionAllAttributesOnFirstLine?: boolean, + preserveWhiteSpacesInComment?: boolean, + enableLogs?: boolean) { + this.indentLength = indentLengh ?? defaultSettings.indentLength; + this.useSingleQuotes = useSingleQuotes ?? defaultSettings.useSingleQuotes; + this.useSelfClosingTags = useSelfClosingTags ?? defaultSettings.useSelfClosingTags; + this.formatOnSave = formatOnSave ?? defaultSettings.formatOnSave; + this.allowSingleQuoteInAttributeValue = allowSingleQuoteInAttributeValue ?? defaultSettings.allowSingleQuoteInAttributeValue; + this.addSpaceBeforeSelfClosingTag = addSpaceBeforeSelfClosingTag ?? defaultSettings.addSpaceBeforeSelfClosingTag; + this.wrapCommentTextWithSpaces = wrapCommentTextWithSpaces ?? defaultSettings.wrapCommentTextWithSpaces; + this.allowWhiteSpaceUnicodesInAttributeValues = allowWhiteSpaceUnicodesInAttributeValues ?? defaultSettings.allowWhiteSpaceUnicodesInAttributeValues; + this.positionFirstAttributeOnSameLine = positionFirstAttributeOnSameLine ?? defaultSettings.positionFirstAttributeOnSameLine; + this.positionAllAttributesOnFirstLine = positionAllAttributesOnFirstLine ?? defaultSettings.positionAllAttributesOnFirstLine; + this.preserveWhiteSpacesInComment = preserveWhiteSpacesInComment ?? defaultSettings.preserveWhiteSpacesInComment; + this.enableLogs = enableLogs ?? defaultSettings.enableLogs; } }