sassoftware / sas-copilot

Issues tracker and feedback project for the SAS coding assistant
9 stars 0 forks source link

Using the copilot "Add Comments" feature is altering the actual code #43

Open Ian-zygz opened 6 months ago

Ian-zygz commented 6 months ago

Describe the bug When using the "Add Comment" feature on highlighted SAS code, the comments are added but the original SAS code highlighted is also changed at the same time the comments are added.

To Reproduce Steps to reproduce the behavior:

  1. I generated SAS code from comments using the following comments - /* sashelp.class table printed and sorted by age */

  2. Accepted the option that gave me this output:

data class_sorted;
    set sashelp.class;
    proc sort data=class_sorted;
        by age;
    run;

    proc print data=class_sorted;
    run;
  1. Highlighted the above code and selected "Add Comments"

  2. The result was a new version of the code with comments. You can see that the code has been re-structured.

/* Sort the class dataset by Age */
data class_sorted;
  set sashelp.class;
run;

/* Sort class_sorted dataset by Age */
proc sort data=class_sorted;
  by age;
run;

/* Print the class_sorted dataset */
proc print data=class_sorted;
run;

Expected behavior I wouldn't expect the code structure to be changed. If this is expected, using this feature on tested code would require additional testing if code is to be changed and would create more effort when building SAS programs.

Desktop (please complete the following information):

leah-gall commented 6 months ago

I had a similar issue. I asked for comments on this data step:

data testset;
    set sashelp.class;
    rename name = var1
           age = var2
           height = var3;
    /* weight = var4
    sex = var5 */
run;

and got this back:

/* Renaming variables and excluding weight and sex variables */
data testset;
   set sashelp.class(rename=(name=var1 age=var2 height=var3));
   /* weight = var4
    sex = var5 */
run;

It didn't consistently give this result, but after trying it quite a few times, it seemed that most of the responses had problems.