The package.json should be valid after the last binding is removed.
Ran into this whilst porting this extension to Visual Studio for Mac. I had to make two changes in the FileTextUtil, although I think the deletion behaviour is fixed by the second change.
Change 1) - The FileTextUtil includes the line endings in its ReadAllText method. It uses File.ReadAllText. I do not think this is correct since the rest of the code uses offsets based on the individual lines and ignores line endings. So I ended up the same code to what is in the VsTextViewTextUtil's ReadAllText method which uses the TryReadLine method and adds each line to a StringBuilder. This returns the text without any line endings.
Change 2) - it seems that if the ',' character preceding the binding section is the first character on the line the GetExtentInfo method returns the wrong information. So I changed the first while loop check to ensure that the next line is read when charCount matches the starting index. https://github.com/mrward/NpmTaskRunner/commit/0059b6e42ae7ab7f347ee86e69a3f24139c6876f
Installed product versions
Description
The package.json file can end up with invalid json after all the bindings are removed.
Steps to recreate
Current behavior
After step 3. the package.json is updated as expected. For example:
After step 4 you end up with the last brace missing.
Expected behaviour
The package.json should be valid after the last binding is removed.
Ran into this whilst porting this extension to Visual Studio for Mac. I had to make two changes in the FileTextUtil, although I think the deletion behaviour is fixed by the second change.
Change 1) - The FileTextUtil includes the line endings in its ReadAllText method. It uses File.ReadAllText. I do not think this is correct since the rest of the code uses offsets based on the individual lines and ignores line endings. So I ended up the same code to what is in the VsTextViewTextUtil's ReadAllText method which uses the TryReadLine method and adds each line to a StringBuilder. This returns the text without any line endings.
Change 2) - it seems that if the ',' character preceding the binding section is the first character on the line the GetExtentInfo method returns the wrong information. So I changed the first while loop check to ensure that the next line is read when charCount matches the starting index. https://github.com/mrward/NpmTaskRunner/commit/0059b6e42ae7ab7f347ee86e69a3f24139c6876f