intersystems / language-server

Repository for the VS Code Language Server
https://marketplace.visualstudio.com/items?itemName=intersystems.language-server
Other
16 stars 6 forks source link

Empty row on end of class definition file after compilation #332

Closed zvondic closed 1 month ago

zvondic commented 1 month ago

I use ISC VSC plugins for development. Cache version is 2018.1.4. When I compile from VSC, I sometimes get blank lines at the end of the file when git changes. Maybe some editing and compiling in class projection and server save to git workspace? It's very annoying. Can you help me? Thanks. Josef

image

isc-bsaviano commented 1 month ago

@zvondic Does this happen only with classes? Do you get another new line every time you compile, or just once?

zvondic commented 1 month ago

Only classes and it is random. My thought is that compiling and saving via the VSC plugin removes the last empty line, but editing the class and compiling from the server-side projection and subsequent saving to the git workspace is saved with an empty line.

isc-bsaviano commented 1 month ago

@zvondic What is your workflow? Based on your screenshot, it looks like you're using client-side editing (editing the files on your local file system that are controlled by git). However, your last comment makes it sounds like you're using server-side editing (editing virtual files like Studio). Which one are you using?

zvondic commented 1 month ago

Yes, i am using client side editing. BU some classes have projection/ I don't use Studio! image But this coomad export from projection modifided classes (added property or method) to git and there are empty lines om end. D ##class(Utils.SourceControl.SyncApi).InternalExportToFS(Class_".cls")

isc-tleavitt commented 1 month ago

The classmethod you're calling there is not InterSystems code, but I've seen similar behavior in https://github.com/intersystems/git-source-control that I'd love to sort out, so following here...

Probably Utils.SourceControl.SyncApi is calling $System.OBJ.ExportUDL (as in https://github.com/intersystems/git-source-control/blob/main/cls/SourceControl/Git/Utils.cls#L1354C28-L1354C49) which adds the extra newline.

isc-bsaviano commented 1 month ago

@zvondic Thanks for the details. Here's my understanding of your workflow:

  1. Open your git folder in VS Code.
  2. Edit a class that has a projection and save it.
  3. The class gets compiled,, triggering the projection.
  4. The projection exports the text of the class to the file in git that you are editing in VS Code.

If I got that right, then I think your projection that does the export is causing the extra line to appear since I couldn't reproduce this issue without it. I don't think you need that projection though. If you're editing the file in VS Code that is tracked by git, the vscode-objectscript extension will update the local copy of the file after it is compiled.

zvondic commented 1 month ago

There are things that are incomprehensible to me in the export, I have to discuss with the author and then I will contact you.

zvondic commented 1 month ago

@isc-bsaviano I found what was causing it. I have a class that has a projection. This projection modifies the class definition and recompiles it and saves it to a git folder using the $system.OBJ.ExportUDL method. And here's the problem, what causes it. It is shown in the picture. Projection is shown in red, and what VSC saved after completion of compilation in green. ExportUDL inserts empty line to end of file. VSC saves file the same as i can see in Cache Studio. But I don't know what to do with, how to force ExportUDL and VSC bring the same results.

image

isc-bsaviano commented 1 month ago

@zvondic I think this is just a difference between how the Atelier API and ExportUDL() return the document content. The Atelier API retuns a JSON array of lines that VS Code joins with the newline character, which doesn't add a newline after the last line. ExportUDL() writes out each line of the document followed by a newline, which adds a newline even after the last line.

isc-bsaviano commented 1 month ago

@zvondic I see you opened a WRC case for this issue so I'm closing this one. Follow the WRC case for updates.