Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoformatter adds spaces around colon in variable declaration #350

Open
pabertay opened this issue Nov 7, 2023 · 2 comments
Open

Autoformatter adds spaces around colon in variable declaration #350

pabertay opened this issue Nov 7, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@pabertay
Copy link

pabertay commented Nov 7, 2023

Please forgive me as I am just a novice, I sincerely hope this isn't a waste of time due to my ignorance.

Basic informations

  • OS: [Windows 10]
  • VSCode version: 1.84.0
  • Extension version: v6.2.0

Further Information

I get a red line and error indication under variable declarations which have a space before the colon. The code still compiles without error, but the linter seems to not like it (not sure if I'm using 'linter' correctly here).

This is a minor issue because when I use autoformat in VS Code (Shift + Alt + F), the formatter adds a space around the colon in variable declarations. I get distracted by these red lines and have to keep deleting the spaces manually.

EDIT: Was wrong, code does not compile with spaces. Linter indicating error is correct, the problem is the auto formatter behaviour

e.g.

new Handle:g_hFile = INVALID_HANDLE;

which looks good in VS Code, ('Handle' is in green, not blue) becomes

new Handle : g_hFile = INVALID_HANDLE;

Now with an error indicated and 'Handle' coloured in blue.

To Reproduce

  1. Create a sp file in VS Code
  2. Declare a variable with no space before the colon, e.g., new Handle:g_hFile = INVALID_HANDLE;
  3. Use VS Code autoformatter (Shift + Alt + F in Windows)
  4. Observe red line and error

Expected behaviour

I presume there should be no error indicated, and the variable type should still be coloured green

Auto formatter should not add spaces here

Error messages

(ERROR (symbol))

Additional

I would like to know if I can make changes to the formatter settings JSON file to prevent spaces around colons in these variable declarations.

@pabertay pabertay added the bug Something isn't working label Nov 7, 2023
@Sarrus1
Copy link
Owner

Sarrus1 commented Nov 7, 2023

Hi, thanks for reporting this!

This is an error on my end. It means that the parser of the lsp (the backend of the extension) does not like Handle:variable.

I don't know of a setting that could help fix that in the formatter :/

Only temporary workaround until I fix this would be to use the new syntax, without the colon.

@pabertay
Copy link
Author

pabertay commented Nov 7, 2023

Thanks for the quick response. I just realised that I was wrong fundamentally - this does not compile. I must have been not saving the file before running the compiler... always something simple! So the bug is not 'displaying an error when there is none' - there is rightfully an error indicated (but I'm sure you spotted this).

I appreciate your workaround suggestion, think I will go with that so I don't have to delete spaces manually. The other workaround would be to not use auto formatter of course 😜

@pabertay pabertay changed the title Linter(?) recognises spaces around colon as error "(ERROR (symbol))" Autoformatter adds spaces around colon in variable declaration Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants