Skip to content

Commit

Permalink
Fixed position all attributes on first line formatting not working (#140
Browse files Browse the repository at this point in the history
)

* naming convention fixes

* removed unused file

* library files fixed

* changelog updated

* v4.1.2
  • Loading branch information
pmahend1 committed Feb 3, 2024
1 parent cf33dd6 commit 76f23ea
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 108 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Binary file modified lib/XmlFormatter.CommandLine.dll
Binary file not shown.
Binary file modified lib/XmlFormatter.CommandLine.exe
Binary file not shown.
Binary file modified lib/XmlFormatter.CommandLine.pdb
Binary file not shown.
Binary file modified lib/XmlFormatter.dll
Binary file not shown.
Binary file modified lib/XmlFormatter.pdb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/formatter.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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();
Expand Down
37 changes: 0 additions & 37 deletions src/jsinputdto.ts

This file was deleted.

132 changes: 64 additions & 68 deletions src/settings.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 76f23ea

Please sign in to comment.