Fixing left the (supposed to be removed End Function) and put the End Sub before the (not removed) End Function causing a compile error.
Before Fix
Private Function Foo(arglist)
End Function
After Fix
Private Sub Foo(arglist)
End Sub
End Function
Don't know if it matters, but the Function that was to be fixed is the last one in the module.
The ConvertToProcedureQuickFix is correctly replacing the FUNCTION and END_FUNCTION tokens of the FunctionStmtContext with SUB and END_SUB tokens, respectively; this isn't as trivial as it seems - it would have been, had this quickfix not been leveraging the rewriter API.
I cannot reproduce this error applying the quickfix immediately after the inspection result got created.
Did you do anything between generating the inspection result and applying the quickfix? Here a setting might play a role: do you have running the inspections after parsing disabled in the settings?
With this disabled I can reproduce the issue by running the inspections, then adding a new line with some whitespace, parsing and then choosing to apply the fix to the inspection.
Most helpful comment
I cannot reproduce this error applying the quickfix immediately after the inspection result got created.
Did you do anything between generating the inspection result and applying the quickfix? Here a setting might play a role: do you have running the inspections after parsing disabled in the settings?
With this disabled I can reproduce the issue by running the inspections, then adding a new line with some whitespace, parsing and then choosing to apply the fix to the inspection.