shinyypig / matlab-in-vscode

A vscode extension for matlab.
MIT License
45 stars 5 forks source link

Command to run a single line #9

Closed fcdimitr closed 1 year ago

fcdimitr commented 1 year ago

Thank you very much for this extension; it works perfectly!

Is adding one more command to run the current line in the file easy (and possibly automatically moving on to the following line)?

Thanks!

shinyypig commented 1 year ago

Thank you for your valuable suggestion. I have added this function in version 0.3.4.

You can press shift+enter to run the current line and move to next line (you can config whether to move next line in the settings).

Glad that you like this extension!

fcdimitr commented 1 year ago

Perfect, thank you very much! I just tried it, and it works like a charm! Would it be easy to adjust it so that when a region is active (multiple lines selected), shift+enter would run the whole region? Just wondering because I have been used to the Julia interface to run parts of a file. 😄

Again, thank you very much!

shinyypig commented 1 year ago

It's relatively simple. Just making some minor modifications to the code can achieve it. Try upgrading to version 0.3.5.

fcdimitr commented 1 year ago

Wow, thank you for the speedy improvements!

I just noticed that when using MATLAB (not Python) executable, it prints the following in the command line:

fprintf( '\n *** (begin) %s ***\n\n', mfilename )

>> disp(evalc(char(sprintf("\n\nfprintf( '\n *** (begin) \n\n\n"))));
Error: Character vector is not terminated properly. 
>> variable_info;

It is likely an issue with the single/double quote. I am unsure if this was introduced with the latest updates or if the same problem existed before. It happens even when running a cell with Cmd+enter.

I don't remember the behavior when running cells with print commands, but I thought they worked perfectly fine before.

Again, thank you for all your work on this, it is a game-changer for MATLAB development!

shinyypig commented 1 year ago

It seems to be a mistake to use evalc to run multiple lines. Have reverted to the previous mode in 0.4.1. Thank you again!

fcdimitr commented 1 year ago

With 0.4.1 I get the following:

fprintf( '\n *** (begin) %s ***\n\n', 'TEST' )
>> fprintf( '\n *** (begin) 
 fprintf( '\n *** (begin) 
          |
Error: Character vector is not terminated properly.

So now it does not use evalc but parsing the file has a similar issue. (I am using the cell-run command)

fcdimitr commented 1 year ago

I think the problem is at %s, maybe you consider every character starting with % as a comment?

shinyypig commented 1 year ago

Yes, it is. I have packaged a new version. Maybe you can help me test it. Unzip the file and install it by clicking Install from VSIX.

matlab-in-vscode-0.4.2.zip

image
fcdimitr commented 1 year ago

It looks like everything works perfectly! You can publish v0.4.2

I observed a temporary CSV file created in the directory for showing the variables in the built-in VS code web viewer.

Screen Shot 2023-06-25 at 12 32 29

You may write in the README that this is temporary and can be safely deleted. Do you think this makes sense?

Other than that, I suggest you close this issue. Thank you!

shinyypig commented 1 year ago

Thanks again!

Actually, the CSV file is designed to be deleted immediately. But if something wrong happens, it could not be deleted. In this case, you can delete it yourself.

Thank you for your remindation. I have added this statement to readme.