FabianLauer / vs-code-xml-format

Simple XML formatter for Visual Studio Code.
https://marketplace.visualstudio.com/items/fabianlauer.vs-code-xml-format
MIT License
7 stars 5 forks source link

cannot format long XML #9

Open Gil80 opened 8 years ago

Gil80 commented 8 years ago

Long XML files are not formatted. Steps:

  1. Open a long XML file
  2. Set language to XML
  3. press command+shift+p / ctrl+shift+p and type 'Format Code'

The option doesn't even show. The same XML can be formatted in Sublime.

FabianLauer commented 8 years ago

Hi @Gil80,

I'm gonna need some more info though so we can figure this out:

And last but not least:

In case the file is too large to post as a comment, a gist will do.

Thanks! 😉

Gil80 commented 8 years ago

Hi @FabianLauer and thanks for replying back.

  1. VS version is 1.5.3
  2. Is an unformatted XML file (single line) extracted from an API response and copied & pasted to VScode. I then press command+K and then M and change language to XML (when copying an XML, VScode treats it as simple text). After changing to XML, I either right-click and select format code, or try to use the Format Code option from the command+shift+P menu. However, even after changing the language to XML, VScode won't always show me the Format Code option. I wasn't able to get a conclusion as to why it doesn't show me this option and why in some cases it does.
  3. Using Sublime Text, I'm able to format the copied text to XML without issues. This will show over 40,000 lines (to give you an indication of file size, or text size) or if it's 1 line then it has 104,628 columns
  4. I'm not able to provide you with the XML file since it's a sensitive document. I was trying to google an unformatted XML file to illustrate the issue, but I wasn't able to find anything.
  5. As for extensions: I have the following (see screenshot):

untitled-1

It's important to stress that the same XML is handled without issues in Sublime and the XML structure is valid.

I know it's not much of a help when I cannot provide the actual XML file. Sorry about that. I do hope that at least some of the information I provided is helpful.

In any case, thank you very much!

FabianLauer commented 8 years ago

From your screenshot I would assume that you're not using this extension, but rather @DotJoshJohnson's XML Tools (repository over here). You should file an issue there.

Anyway, thanks for the info! 😄

Gil80 commented 8 years ago

Hi,

I got the screenshot wrong. This screenshot was taken after I tried Josh's plugin. But the issue I described was when I used your plugin :)

However, having tested it more with Josh's plugin, it seems that there's an issue with VScode. But it also seems that this issue can only be resolved by plugins and that VScode developers won't fix it.

Sorry about the confusion.

FabianLauer commented 8 years ago

...it seems that there's an issue with VScode. But it also seems that this issue can only be resolved by plugins and that VScode developers won't fix it.

Okay — can you please describe the issue? Or maybe there's a bug report in VS Code that tracks it, if so a link to that would be great, if not, please open an issue for the problem at their repo over here. Thanks!

Gil80 commented 8 years ago

They have removed Format Code from VScode, therefore I hardly believe they'll do anything about it. See here: https://github.com/Microsoft/vscode/issues/71 "XML formatting has been removed as it was based on the HTML formatter and had lot of bugs. We hope that an extension can provide a high quality XML formatter."

And your comment is right below that :)

So what VScode really do when I open a large XML file:

  1. Change from plain text to XML - pass
  2. right-click to select 'Format Code' or use the F1 menu / command+shift+p / - Fail

The Format Code doesn't even show.

I've attached the file. copy it's contents and past it to a new untitled document in vscode. Change it to xml and format it.

file.txt

FabianLauer commented 8 years ago

Hmm. First off, thanks for the file!

I can't seem to reproduce the problem, though. I use this plugin on Mac and Windows in VS Code 1.5.3 and haven't had issues yet. I'll try to reproduce it and I'll come up with a fix if I can find something.

The one thing you could try if you have the time is re-open VS Code, then open the developer tools (Help Menu -> Toggle Developer Tools), change the language mode to XML and check whether there's any errors in the developer console.

Thanks for your help, very much appreciated 👍

Gil80 commented 8 years ago

Please see video capture:

https://goo.gl/4tP5rT

Let me know if you can't access the file. In the video, I used the same XML I sent you. Notice how I change it to XML and that I don't have Format Code option. The extension panel is open so you can view what I've got installed.

After all, this may not be a bug with your extension, but with VScode.

Thanks!

FabianLauer commented 8 years ago

Reopening... still not able to reproduce the issue, but there's been some more similar reports over at the marketplace for 1.5.2 and 1.6.1 😕

anwar3606 commented 3 years ago

confirmed with a 100mb xml file. each line is not more then 200 char.