Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The space will be generated on both sides of the "\" or "/" in strings. #109

Open
DWin233 opened this issue Jun 8, 2021 · 5 comments
Open
Assignees

Comments

@DWin233
Copy link

DWin233 commented Jun 8, 2021

Hello, I found a problem or bug when i use your tool to format my code. The space will be automatically generated on both sides of the "" or "/" in strings.
QQ截图20210608100827
image

@davidvarga davidvarga self-assigned this Oct 8, 2021
@davidvarga
Copy link
Owner

davidvarga commented Oct 8, 2021

Hi, I cannot reproduce the issue.
I am trying with Matlab R2020b, executing MBeautify.formatCurrentEditorPage() on the following content using defautl configuration:

self.resultDir = self.totalDir + path + "/";
self.resultDir = self.totalDir + path + "\";
self.totalDir = ".\results\";

The result is the same as the input in my case.

Is there any special context I am missing for my tests?

@DWin233
Copy link
Author

DWin233 commented Oct 8, 2021

My code is edited with Matlab 2020a. Here is the test code:

self=struct();  
path="1";  
self.totaldir=".\results\";
self.resdir=self.totaldir+path+"\";

After executing MBeautify.formatCurrentEditorPage() using default configuration, this code changes to :

self = struct();  
path = "1";  
self.totaldir = " .\ results \ ";  
self.resdir = self.totaldir + path + " \ ";  

I don't know whether this difference is due to the different versions of Matlab we use.

@davidvarga
Copy link
Owner

Hi @DWin233 ,

I tried again, this time with R2020b, still no "luck" reporducing it.

Are you using the default configuration or a moified one?

@lvdgraaff
Copy link

Hi David,

Thanks a lot for creating MBeautifier. Its a great tool and I'm using it a lot. Today I bumped into the same behavior as described in this issue. In my case I format:

path = "\\host\folder\file";

which results in

path = " \  \ host \ folder \ file";

I use the MBeautify.formatCurrentEditorPage() function for formatting. I use v1.3.2. Platform: Windows 10. Matlab version R2023a. As far as I'm aware I use a default configuration but if there are any settings that might impact this behavior, let me know.

I would really appreciate if you would take another look at this issue and I'm happy to provide you with any further information.

Best,
Leon

@lvdgraaff
Copy link

lvdgraaff commented Nov 6, 2023

Just some debugging:

Using chars:
path = '\\host\folder\file';                ->    path = '\\host\folder\file';                (Correct)

Using string:
path = "//host/folder/file";               ->    path = " /  / host / folder / file";      (Incorrect)

Using other operators in a string:
text = "a+b"                                      ->    text = "a + b"                                   (Incorrect)

In comments
% //host/folder/file                           ->    % //host/folder/file                          (Correct)

In text arguments
disp //host/folder/file                        ->   disp //host/folder/file                       (Correct)

So it appears this problem relates to the string environment not being recognized as such. Note the latter example contradicts #122.

  • formatFile has the same issue as formatCurrentEditorPage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants