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

[BUG] Using periods in labels #96

Closed
nlehmanDLC opened this issue May 6, 2020 · 9 comments · Fixed by #106
Closed

[BUG] Using periods in labels #96

nlehmanDLC opened this issue May 6, 2020 · 9 comments · Fixed by #106
Assignees
Labels
bug Something isn't working resolved Issue resolved or enhancement added
Milestone

Comments

@nlehmanDLC
Copy link

I'm using VS Code 1.44 on Windows Server 2016. I'm using version 2.0.6 of MV Basic.

I often use periods to separate words in my labels. For example:

* Some method
SOME.METHOD:
      FOO = BAR;
      RETURN

When I run the code format, it does not recognize these as labels.

What I end up doing is changing your regex found in client\out\extension.js to:

let rLabel = new RegExp("(^[0-9]+\\s)|(^[0-9]+:\\s)|(^[\\w.]+:)");

I have to do this each time you put out a new version of your extension. It's no big deal but this time was a little bit of a pain since it was minified.

Would it be ok to add periods in the label regex or maybe an option that would let the user over-ride with their own regex?

Thanks so much for this extension. It has helped me so much!

@kpowick
Copy link
Member

kpowick commented May 6, 2020

Never noticed that before. Thanks for the feedback. I'll look at getting that RegEx fix into the next update.

@kpowick
Copy link
Member

kpowick commented May 6, 2020

Actually, I cannot reproduce the issue. Dot-separated labels in my own code, and your example, are recognized in 2.0.6.

If you check the folder .vscode/extensions, do you only have one version of mvextensions.mvbasic-N.N.N, where N.N.N is the version number (e.g. 2.0.6)?

Perhaps try reinstalling via the following procedure:

  1. Remove the extension via the Extensions panel in the VS Code application.
  2. Close all instances of VS Code.
  3. Under the folder .vscode/extensions, delete all folders named mvextensions.mvbasic-N.N.N.
  4. Open VS Code.
  5. Reinstall the extension from the marketplace.

Edit: I'm running VS Code on macOS, but I have it installed on Linux and Windows. I'll check the behaviour there as well.

@nlehmanDLC
Copy link
Author

I had both 2.0.5 and 2.0.6 in my extensions folder. I followed your steps to remove. When I re-installed I still have the same issue.

Here are the customized settings I use for this extension:

"MVBasic.useCamelCase": false,
"MVBasic.margin": 6,
"MVBasic.languageType": "UniVerse",

Here is a screenshot before I do code formatting:
image

And here is what happens after I run the code formatting:
image

Adding a dot into that regex for rlabel fixes the issue for me. Are there any other tests I can do that will help debug?

@kpowick
Copy link
Member

kpowick commented May 6, 2020

Ok. I see the issue now. It's not the code linter, it's the syntax highlighting you're missing. And the dot isn't the issue, it's the leading spaces (your margin setting) that is causing the highlighter to "miss" your labels. Actually, non dotted labels have the same problem if the margin is greater than zero.

I'll get this fixed-up and post the RegEx for the next update here.

Thanks for the extra details.

@itsxallwater itsxallwater added the bug Something isn't working label May 6, 2020
@itsxallwater itsxallwater reopened this May 6, 2020
@itsxallwater itsxallwater changed the title Using periods in labels [BUG] Using periods in labels May 6, 2020
@itsxallwater itsxallwater added this to the v2.0.7 milestone May 6, 2020
@kpowick
Copy link
Member

kpowick commented May 6, 2020

I believe I have a RegEx fix for the syntax highlighting problem of labels beginning with spaces.

The updated RegEx for label recognition is: "^\\s*([\\w.]+:(?!=)|[0-9]+)"

Several files are affected, which you can review in this commit.

@kpowick
Copy link
Member

kpowick commented May 6, 2020

@nlehmanDLC, If updating your live install by hand, please be sure to check all commits as of 2020-05-06 in the branch that I opened for this issue.

@nlehmanDLC
Copy link
Author

The RegEx looks fine to me. For me the addition of the dot was the important thing. I didn't really need the part with the leading spaces which might have been confusing based on the screen shots I posted. The first screen shot represents the way I wanted the code to be formatted, the second shows what happens after running the code format. Since it wasn't being matched as a label it was indenting the label as part of the regular code.

@itsxallwater
Copy link
Member

@kpowick I pulled your branch and ran a quick build to put together a preview for 2.0.7 with this change included. Might help out for testing. Easier to accomplish now that the final build output is tiny.

  1. Take care to set the version in the package.json files (vsce can do this for you but for these sorts of things I like to keep it manual).
  2. npm run compile
  3. npm run webpack
  4. vsce package
  5. Zip and upload the .vsix file.

mvbasic-2.0.7.zip

@kpowick
Copy link
Member

kpowick commented May 6, 2020

@nlehmanDLC Sure thing, but I had to come up with a RegEx that solved more than just the "dot" problem. Dotted labels actually work fine in 2.0.6, IF there are no leading spaces (margin) before the label. Your report uncovered that problem.

Thanks again. Tweaking the syntax highlighting is an ongoing process.

@kpowick kpowick added resolved Issue resolved or enhancement added and removed resolved Issue resolved or enhancement added labels May 6, 2020
kpowick pushed a commit that referenced this issue Jun 10, 2020
- Issue #45: Alignment of If/Else
- Issue #96: Allow periods in labels
- Issue #99: Corrected Label error with GOTO/GOSUB.
- Issue #104: Corrected For/Next with leading label
- Issue #105: Changed GOTO scope jumping message from Error to Warning
- RegEx: Label comments to include "REM, *, and !"
- NEXT can be used without FOR variable.
@itsxallwater itsxallwater linked a pull request Jun 11, 2020 that will close this issue
itsxallwater added a commit that referenced this issue Jun 11, 2020
* RegEx fix for labels with leading spaces.

* 98-Issue linting with multiple levels of quoting

* RegEx improvement for quoted strings

* Replace parenthesis and quoted strings with empty ones.
- Removed repetitive Trim()s
- Removed unnecessary RegEx tests
- Simplified line split on semicolon due to above changes.
- Results: Faster execution. Better coverage for split on semicolon

* - Cleanup lines[] array at start so repeated test/replace not needed
- Removed unnecessary trim()s
- Removed boolean equality tests. if(x.test == true) vs if(x.test)
- Fixed GOTO/GOSUB when followed by more than one space GOTO <s><s> 100

* RegEx fix-ups to support recent changes

* Corrected comment

* Linter RegEx cleanup

* FOR/NEXT tracking improvements and updated error messages
- Nested For/Next statements now validated
- NEXT with no variable is now allowed
- One line per error: Removed extraneous, repeated diagnostic messages
- Reworded / Clarified some error messages for consistency

* Minor code clean-up

* Replace char-at-a-time split on ; with split(";")

* Maintain original character spacing for Intellisense error markers
- RegEx improvements and consistency between client and server
- Improved getWord() function

* Corrected indentation for ELSE END with trailing comment (issue #45)

* Corrects Label error with GOTO/GOSUB. Issue #99
- Also now allows dotted numeric labels such as GOTO 100.5

* Revert "Corrects Label error with GOTO/GOSUB. Issue #99"

This reverts commit 68b0166.

* Inspect TM Scopes->Inspect Editor Token and Scopes

* Fix error processing customWordPath when last
line is blank. May relate to #24.

* Changed GOTO/GOSUB scope jumping message from Error to Warning

* Numerous updates related to For/Next and Label tracking
- Issue #45: Alignment of If/Else
- Issue #96: Allow periods in labels
- Issue #99: Corrected Label error with GOTO/GOSUB.
- Issue #104: Corrected For/Next with leading label
- Issue #105: Changed GOTO scope jumping message from Error to Warning
- RegEx: Label comments to include "REM, *, and !"
- NEXT can be used without FOR variable.

* Shipping 2.0.7

Co-authored-by: Kevin Powick <[email protected]>
Co-authored-by: Ian McGowan <[email protected]>
Co-authored-by: Peter Schellenbach <[email protected]>
itsxallwater added a commit that referenced this issue Jun 11, 2020
* RegEx fix for labels with leading spaces.

* 98-Issue linting with multiple levels of quoting

* RegEx improvement for quoted strings

* Replace parenthesis and quoted strings with empty ones.
- Removed repetitive Trim()s
- Removed unnecessary RegEx tests
- Simplified line split on semicolon due to above changes.
- Results: Faster execution. Better coverage for split on semicolon

* - Cleanup lines[] array at start so repeated test/replace not needed
- Removed unnecessary trim()s
- Removed boolean equality tests. if(x.test == true) vs if(x.test)
- Fixed GOTO/GOSUB when followed by more than one space GOTO <s><s> 100

* RegEx fix-ups to support recent changes

* Corrected comment

* Linter RegEx cleanup

* FOR/NEXT tracking improvements and updated error messages
- Nested For/Next statements now validated
- NEXT with no variable is now allowed
- One line per error: Removed extraneous, repeated diagnostic messages
- Reworded / Clarified some error messages for consistency

* Minor code clean-up

* Replace char-at-a-time split on ; with split(";")

* Maintain original character spacing for Intellisense error markers
- RegEx improvements and consistency between client and server
- Improved getWord() function

* Corrected indentation for ELSE END with trailing comment (issue #45)

* Corrects Label error with GOTO/GOSUB. Issue #99
- Also now allows dotted numeric labels such as GOTO 100.5

* Revert "Corrects Label error with GOTO/GOSUB. Issue #99"

This reverts commit 68b0166.

* Inspect TM Scopes->Inspect Editor Token and Scopes

* Fix error processing customWordPath when last
line is blank. May relate to #24.

* Changed GOTO/GOSUB scope jumping message from Error to Warning

* Numerous updates related to For/Next and Label tracking
- Issue #45: Alignment of If/Else
- Issue #96: Allow periods in labels
- Issue #99: Corrected Label error with GOTO/GOSUB.
- Issue #104: Corrected For/Next with leading label
- Issue #105: Changed GOTO scope jumping message from Error to Warning
- RegEx: Label comments to include "REM, *, and !"
- NEXT can be used without FOR variable.

* Shipping 2.0.7

* Re-introduce accidentally deleted /doc files

* Fixes issue 107: FOR/NEXT error when no whitespace after FOR variable.

* Shipping 2.0.8

Co-authored-by: Kevin Powick <[email protected]>
Co-authored-by: Ian McGowan <[email protected]>
Co-authored-by: Peter Schellenbach <[email protected]>
itsxallwater added a commit that referenced this issue Sep 1, 2020
* RegEx fix for labels with leading spaces.

* 98-Issue linting with multiple levels of quoting

* RegEx improvement for quoted strings

* Replace parenthesis and quoted strings with empty ones.
- Removed repetitive Trim()s
- Removed unnecessary RegEx tests
- Simplified line split on semicolon due to above changes.
- Results: Faster execution. Better coverage for split on semicolon

* - Cleanup lines[] array at start so repeated test/replace not needed
- Removed unnecessary trim()s
- Removed boolean equality tests. if(x.test == true) vs if(x.test)
- Fixed GOTO/GOSUB when followed by more than one space GOTO <s><s> 100

* RegEx fix-ups to support recent changes

* Corrected comment

* Linter RegEx cleanup

* FOR/NEXT tracking improvements and updated error messages
- Nested For/Next statements now validated
- NEXT with no variable is now allowed
- One line per error: Removed extraneous, repeated diagnostic messages
- Reworded / Clarified some error messages for consistency

* Minor code clean-up

* Replace char-at-a-time split on ; with split(";")

* Maintain original character spacing for Intellisense error markers
- RegEx improvements and consistency between client and server
- Improved getWord() function

* Corrected indentation for ELSE END with trailing comment (issue #45)

* Corrects Label error with GOTO/GOSUB. Issue #99
- Also now allows dotted numeric labels such as GOTO 100.5

* Revert "Corrects Label error with GOTO/GOSUB. Issue #99"

This reverts commit 68b0166.

* Inspect TM Scopes->Inspect Editor Token and Scopes

* Fix error processing customWordPath when last
line is blank. May relate to #24.

* Changed GOTO/GOSUB scope jumping message from Error to Warning

* Numerous updates related to For/Next and Label tracking
- Issue #45: Alignment of If/Else
- Issue #96: Allow periods in labels
- Issue #99: Corrected Label error with GOTO/GOSUB.
- Issue #104: Corrected For/Next with leading label
- Issue #105: Changed GOTO scope jumping message from Error to Warning
- RegEx: Label comments to include "REM, *, and !"
- NEXT can be used without FOR variable.

* Shipping 2.0.7

* Re-introduce accidentally deleted /doc files

* Fixes issue 107: FOR/NEXT error when no whitespace after FOR variable.

* Shipping 2.0.8

* Issue #110: Do not change indentation of comment lines

* Issue #111: Added user setting to control indentation of comment lines.

* Bump elliptic from 6.5.2 to 6.5.3 (#119)

Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](indutny/elliptic@v6.5.2...v6.5.3)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update Extension Guide.md

Updated AccuTerm connector and host program links.

* Feature request 113 (#121)

* Update package.json

Added MVBasic.customFunctionPath

* Update server.ts

added functionality to Load CustomFunction definition

* Add files via upload

* Update Extension Guide.md

added documentation for Custom functions and subroutines 6.8

* Update server.ts

Removed `data: functions[i].index,` for now since Microsoft has not responded yet.  It works without it, and it's no longer in the Microsoft API documentation.

* - Fix issue with startLoop/endLoop in server code parser
- Clean up unused variable in server
- Expand docs on new customFunctions feature

* Shipping 2.0.9

Co-authored-by: Kevin Powick <[email protected]>
Co-authored-by: Ian McGowan <[email protected]>
Co-authored-by: Peter Schellenbach <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brent Blair <[email protected]>
itsxallwater added a commit that referenced this issue Sep 2, 2020
* RegEx fix for labels with leading spaces.

* 98-Issue linting with multiple levels of quoting

* RegEx improvement for quoted strings

* Replace parenthesis and quoted strings with empty ones.
- Removed repetitive Trim()s
- Removed unnecessary RegEx tests
- Simplified line split on semicolon due to above changes.
- Results: Faster execution. Better coverage for split on semicolon

* - Cleanup lines[] array at start so repeated test/replace not needed
- Removed unnecessary trim()s
- Removed boolean equality tests. if(x.test == true) vs if(x.test)
- Fixed GOTO/GOSUB when followed by more than one space GOTO <s><s> 100

* RegEx fix-ups to support recent changes

* Corrected comment

* Linter RegEx cleanup

* FOR/NEXT tracking improvements and updated error messages
- Nested For/Next statements now validated
- NEXT with no variable is now allowed
- One line per error: Removed extraneous, repeated diagnostic messages
- Reworded / Clarified some error messages for consistency

* Minor code clean-up

* Replace char-at-a-time split on ; with split(";")

* Maintain original character spacing for Intellisense error markers
- RegEx improvements and consistency between client and server
- Improved getWord() function

* Corrected indentation for ELSE END with trailing comment (issue #45)

* Corrects Label error with GOTO/GOSUB. Issue #99
- Also now allows dotted numeric labels such as GOTO 100.5

* Revert "Corrects Label error with GOTO/GOSUB. Issue #99"

This reverts commit 68b0166.

* Inspect TM Scopes->Inspect Editor Token and Scopes

* Fix error processing customWordPath when last
line is blank. May relate to #24.

* Changed GOTO/GOSUB scope jumping message from Error to Warning

* Numerous updates related to For/Next and Label tracking
- Issue #45: Alignment of If/Else
- Issue #96: Allow periods in labels
- Issue #99: Corrected Label error with GOTO/GOSUB.
- Issue #104: Corrected For/Next with leading label
- Issue #105: Changed GOTO scope jumping message from Error to Warning
- RegEx: Label comments to include "REM, *, and !"
- NEXT can be used without FOR variable.

* Shipping 2.0.7

* Re-introduce accidentally deleted /doc files

* Fixes issue 107: FOR/NEXT error when no whitespace after FOR variable.

* Shipping 2.0.8

* Issue #110: Do not change indentation of comment lines

* Issue #111: Added user setting to control indentation of comment lines.

* Bump elliptic from 6.5.2 to 6.5.3 (#119)

Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](indutny/elliptic@v6.5.2...v6.5.3)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update Extension Guide.md

Updated AccuTerm connector and host program links.

* Feature request 113 (#121)

* Update package.json

Added MVBasic.customFunctionPath

* Update server.ts

added functionality to Load CustomFunction definition

* Add files via upload

* Update Extension Guide.md

added documentation for Custom functions and subroutines 6.8

* Update server.ts

Removed `data: functions[i].index,` for now since Microsoft has not responded yet.  It works without it, and it's no longer in the Microsoft API documentation.

* - Fix issue with startLoop/endLoop in server code parser
- Clean up unused variable in server
- Expand docs on new customFunctions feature

* Shipping 2.0.9

* Update server.ts

It looks like I left the line `customFunctionPath = settings.MVBasic.customFunctionPath;` out of the merge.

* Shipping v2.0.10

Co-authored-by: Kevin Powick <[email protected]>
Co-authored-by: Ian McGowan <[email protected]>
Co-authored-by: Peter Schellenbach <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brent Blair <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved Issue resolved or enhancement added
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants