microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
733 stars 243 forks source link

IntelliSensedon't replace the whole filed when used in the middle #7817

Open MaxFalcone opened 1 month ago

MaxFalcone commented 1 month ago

1. Describe the bug image Lets say I have a piece of code and the field was renamed elsewhere. Now I want to change reference to the new name. I set cursor in the middle of the field and press Ctrl+Space, IntelliSense kicks-in and proposes correct new name of the field.

When I hit Enter new field name is inserted just in the middle of the line wrecking formating. I have to delete the rest of the old field name manually. image

2. To Reproduce See description.

  1. Create a field
  2. Referece this field in assignment or validate statement.
  3. Rename field without using Refactoring tools. As if the field is in another module that you have no control over.
  4. Try fixing your code using IntelliSense.

Change from

VATPostingSetup.Get(Vendor."VAT Bus. Posting Group", Vendor."VAT Agent Prod. Posting Group");

To (AWK is a company suffix)

VATPostingSetup.Get(Vendor."VAT Bus. Posting Group", Vendor."VAT Agent Prod PostingGroupAWK");

3. Expected behavior When I hit Enter to accept IntelliSens proposal whole field name string should be changed from "VAT Agent Prod. Posting Group" to "VAT Agent Prod PostingGroupAWK" without any leftowers.

4. Actual behavior Rest of the old field name that was to the righ of the cursor is left hanging and must be deleted manually.

5. Versions:

dannoe commented 1 month ago

You can just set "editor.suggest.insertMode": "replace" in your vscode settings.

Edit: This does not work if the replaced field name contains a dot. (.) Edit2: If the cursor is after the dot it still works.

MaxFalcone commented 1 month ago

Thanks a lot! It does partially work. The fact that it doesn't work if field name hase dot in it is again, I believe, because of strange language tokens parsing by AL extension that was causing other issue(#7744) I raised. But it was rejected. I wonder if thes problems have common cause.