Skip to content

Commit

Permalink
Fix for infinite formatting progress on errored file (pmahend1#89)
Browse files Browse the repository at this point in the history
* resolve [] instead of reject to prevent infinite formatting editing progress

* updated changelog and readme
release notes added

* yarn upgrade

* v1.3.4
  • Loading branch information
pmahend1 authored Dec 27, 2021
1 parent 0fd2e8c commit 0e5b45c
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 29 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

### 1.3.4: 27-Dec-2021

- Fix for infinite formatting progress on errored XML file. [#88](https://github.com/pmahend1/PrettyXML/issues/88)

### 1.3.3: 23-Dec-2021

- Missing release notes not displaying bugfix.
Expand Down
89 changes: 69 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
# Pretty XML

<img src='./images/logo.png' width='200' height='200' />
<img src='./images/logo.png' width='200' height='200' />

[What is it?](#what-is-it)

[Features](#features)
[1. Prettify XML (XML Formatting)](#1-prettify-xml-xml-formatting)
[2. Pretty XML: Minimize](#2-pretty-xml-minimize)

[Keyboard Shortcuts](#keyboard-shortcuts)

[Settings](#settings)

[Requirements](#requirements)

[Installation](#installation)

[Known Issues](#known-issues)

[Change Log](CHANGELOG.md#change-log)

[For more information](#for-more-information)

------------------

> 🆕 What's new in version 1.x.x
>
Expand All @@ -13,22 +35,38 @@
>
> Linux support added with version 1.1.0
--------------------

## What is it?

Pretty XML is a XML formatter extension for Visual Studio Code and VSCodium. It formats XML documents just like Visual Studio on Windows.
**Supported file extensions**: xml, xaml, xsd, xsl, plist, mobileconfig, config, csproj, axml, resx and all other XML type of files.

**Supported file extensions**:
- xml
- xaml
- axml
- xsd
- xsl
- plist
- mobileconfig
- config
- csproj
- resx and all other XML type of files.

There is also **Visual Studio for Mac** version of this extension. Check it out at [PrettyXML.VSMac](https://github.com/pmahend1/PrettyXML.VSMac)

Suggestions , improvement PRs are welcome.
Suggestions, improvement PRs are welcome.

[![License.](https://img.shields.io/github/license/pmahend1/PrettyXML?style=flat-square&label=License)](https://choosealicense.com/licenses/mit/)

[![License](https://img.shields.io/github/license/pmahend1/PrettyXML?style=flat-square&label=License)](https://choosealicense.com/licenses/mit/)
[![Version.](https://vsmarketplacebadge.apphb.com/version/PrateekMahendrakar.PrettyXML.svg?logo=visual-studio-code&style=for-the-badge)](https://marketplace.visualstudio.com/items?itemName=PrateekMahendrakar.prettyxml)

[![Version](https://vsmarketplacebadge.apphb.com/version/PrateekMahendrakar.PrettyXML.svg?logo=visual-studio-code&style=for-the-badge)](https://marketplace.visualstudio.com/items?itemName=PrateekMahendrakar.prettyxml)
![Deploy.](https://img.shields.io/github/workflow/status/pmahend1/prettyxml/Deploy%20CI?color=brightgreen&label=Deploy%20CI&style=flat-square&logo=github) ![Installs](https://vsmarketplacebadge.apphb.com/installs/PrateekMahendrakar.PrettyXML.svg?style=flat-square&label=Installs&logo=data:img/png:images/logo.png) ![Downloads](https://vsmarketplacebadge.apphb.com/downloads/PrateekMahendrakar.PrettyXML.svg?style=flat-square&label=Downloads) ![Rating](https://vsmarketplacebadge.apphb.com/rating-star/PrateekMahendrakar.PrettyXML.svg?style=flat-square&label=Rating)

![Deploy](https://img.shields.io/github/workflow/status/pmahend1/prettyxml/Deploy%20CI?color=brightgreen&label=Deploy%20CI&style=flat-square&logo=github) ![Installs](https://vsmarketplacebadge.apphb.com/installs/PrateekMahendrakar.PrettyXML.svg?style=flat-square&label=Installs&logo=data:img/png:images/logo.png) ![Downloads](https://vsmarketplacebadge.apphb.com/downloads/PrateekMahendrakar.PrettyXML.svg?style=flat-square&label=Downloads) ![Rating](https://vsmarketplacebadge.apphb.com/rating-star/PrateekMahendrakar.PrettyXML.svg?style=flat-square&label=Rating)

---
![prettify gif.](./images/Prettify.gif)

![prettify gif](./images/Prettify.gif)
--------------------

## Features

Expand All @@ -44,17 +82,19 @@ Right Click and Select Prettify XML or use [shortcut](#keyboard-shortcuts)

_before_

![Before](./images/before.png)
![Before.](./images/before.png)

**After**

![After](./images/after.png)
![After.](./images/after.png)

### 2. Pretty XML: Minimize

Minimizes XML.

![minimize gif](./images/Minimize.gif)
![minimize gif.](./images/Minimize.gif)

--------------------

## Keyboard Shortcuts

Expand All @@ -69,6 +109,8 @@ Minimizes XML.
>
> You can change these in **Preferences → Keyboard Shortcuts** if you want.
--------------------

## Settings

These will be for **Prettify XML** command.
Expand All @@ -84,30 +126,37 @@ These will be for **Prettify XML** command.
| prettyxml.settings.wrapCommentTextWithSpaces | true | Wraps comment text with a single space |
| prettyxml.settings.allowWhiteSpaceUnicodesInAttributeValues | true | Allows white space unicodes in attribute values |

![Settings Image](./images/settings.png)
![Settings Image.](./images/settings.png)

--------------------

## Requirements

VS Code 1.58 or higher.
- VS Code 1.58 or higher.
> **Important!**
>
> You will need .Net SDK or mono installed on your machine and should be accessible through terminal.
- Linux users may have to install [Muhammad-Sammy C#](https://open-vsx.org/extension/muhammad-sammy/csharp) or [Microsoft C#](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) extension.

--------------------

## Installation

Visual Studio Code - [Visual Studio MarketPlace](https://marketplace.visualstudio.com/items?itemName=PrateekMahendrakar.prettyxml)

For VSCodium - [open-vsx.org](https://open-vsx.org/extension/PrateekMahendrakar/prettyxml)

> **Important!**
>
> You will need .Net SDK or Mono installed on your machine.
--------------------

## Known Issues

Limited DTD support.
Issues can be reported at [issues section](https://github.com/pmahend1/PrettyXML/issues)
- Limited DTD support.
- Formats valid XML files only. Syntax errors are displayed.

## Release Notes
Issues can be reported at [issues section](https://github.com/pmahend1/PrettyXML/issues)

See [Change Log](./CHANGELOG.md)
--------------------

### For more information

Expand Down
4 changes: 4 additions & 0 deletions lib/newReleaseNotifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,9 @@
{
"version": "1.3.3",
"updateNotes": "🆕 Now you can set Pretty XML as your default XML formatter.\n Once done you can use formatting keybind to format, default is usually 'Shift + Alt + F'. \n You can still use Pretty XML command key 'Ctrl + K L' too.\n Linux is supported now."
},
{
"version": "1.3.4",
"updateNotes": "🆕 Now you can set Pretty XML as your default XML formatter.\n Once done you can use formatting keybind to format, default is usually 'Shift + Alt + F'. \n You can still use Pretty XML command key 'Ctrl + K L' too.\n Linux is supported now."
}
]
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": "1.3.3",
"version": "1.3.4",
"publisher": "PrateekMahendrakar",
"repository": {
"url": "https://github.com/pmahend1/prettyxml.git"
Expand Down
10 changes: 5 additions & 5 deletions src/prettyXmlFormattingEditProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class PrettyXmlFormattingEditProvider implements DocumentFormattingEditPr

var formattedText = await vscode.window.withProgress(progressOptions, (progress) =>
{
var promise = new Promise<string>((resolve, reject) =>
var promise = new Promise<string>(async (resolve, reject) =>
{
progress.report({ message: "Formatting...", increment: 0 });

Expand All @@ -53,25 +53,25 @@ export class PrettyXmlFormattingEditProvider implements DocumentFormattingEditPr
var formattedText = await this.formatter.formatXml();
progress.report({ message: "Formatting...", increment: 75 });
resolve(formattedText);

progress.report({ message: "Formatting...", increment: 100 });
}
catch (error)
{
reject(error);
return reject(error);
}
}, 250);
});

return promise;
});
const replacer = TextEdit.replace(documentRange, formattedText);
resolve([ replacer ]);
return resolve([ replacer ]);
}
catch (error)
{
console.error(error);
reject(error);
return resolve([]);
}
});
}
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@
integrity sha512-KB0sixD67CeecHC33MYn+eYARkqTheIRNuu97y2XMjR7Wu3XibO1vaY6VBV6O/a89SPI81cEUIYT87UqUWlZNw==

"@types/node@^16.4.13":
version "16.11.14"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.14.tgz#4939fb42e5b0ffb3ea7e193c28244fe7414977a6"
integrity sha512-mK6BKLpL0bG6v2CxHbm0ed6RcZrAtTHBTd/ZpnlVPVa3HkumsqLE4BC4u6TQ8D7pnrRbOU0am6epuALs+Ncnzw==
version "16.11.17"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.17.tgz#ae146499772e33fc6382e1880bc567e41a528586"
integrity sha512-C1vTZME8cFo8uxY2ui41xcynEotVkczIVI5AjLmy5pkpBv/FtG+jhtOlfcPysI8VRVwoOMv6NJm44LGnoMSWkw==

"@types/responselike@*", "@types/responselike@^1.0.0":
version "1.0.0"
Expand Down

0 comments on commit 0e5b45c

Please sign in to comment.