AL icon indicating copy to clipboard operation
AL copied to clipboard

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

Open MaxFalcone opened this issue 1 year ago • 3 comments

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:

  • AL Language: v13.1.1065068
  • Visual Studio Code: Version: 1.92.0 (user setup) Commit: b1c0a14de1414fcdaa400695b4db1c0799bc3124 Date: 2024-07-31T23:26:45.634Z Electron: 30.1.2 ElectronBuildId: 9870757 Chromium: 124.0.6367.243 Node.js: 20.14.0 V8: 12.4.254.20-electron.0 OS: Windows_NT x64 10.0.22631
  • Business Central: 24.0
  • List of Visual Studio Code extensions that you have installed:

MaxFalcone avatar Aug 07 '24 12:08 MaxFalcone

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.

dannoe avatar Aug 14 '24 06:08 dannoe

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.

MaxFalcone avatar Aug 14 '24 08:08 MaxFalcone