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
Suggestion: Improvement of check if filepath is relative #821
Comments
Have you actually ran into an issue and proven that this fixes the issue or is this just an idea from eyeballing the code? I don't remember the specifics, but I think I was doing it this way because the filepath is actually generated by Eclipse where the path always starts with Line 615 in a6f25a6
It's been awhile since I've looked at this code so it's entirely possible you're right, and I'm sure there are opportunities for refactoring. However, in this instance, I believe there is a reason for using |
Also, here's a link to my rant from almost 7 years ago which might be relevant: |
Thank you for taking an interest in Vrapper! I believe that Eclipse uses URIs and hence the URI path separator (i.e. a regular slash) in its file APIs, and so I agree with what @keforbes is saying. I'm running Windows so I'll double-check when I got some free time (January tends to be a time to meet friends and family, so free time tends to be scarce). |
I have found that you check if a filepath is relative by “filepath.startWith(“/”)”. However the File offer an official API File. isAbsolute().
isAbsolute
public boolean isAbsolute()
Tests whether this abstract pathname is absolute. The definition of absolute pathname is system dependent. On UNIX systems, a pathname is absolute if its prefix is "/". On Microsoft Windows systems, a pathname is absolute if its prefix is a drive specifier followed by "\", or if its prefix is "\\".
Returns:
true if this abstract pathname is absolute, false otherwise
This will not only meet your need, but also deal with the different expression of relative file path.
Although there may be a lot of work, i think it is worth refactoring it.
Detail websites and lines are listed below
22 | https://github.com/vrapper/vrapper/blob/master/net.sourceforge.vrapper.core/src/net/sourceforge/vrapper/vim/commands/EditFileCommand.java
59 | https://github.com/vrapper/vrapper/blob/master/plugins/ports/net.sourceforge.vrapper.plugin.splitEditor/src/net/sourceforge/vrapper/plugin/splitEditor/commands/SplitEditorCommand.java
235 | https://github.com/vrapper/vrapper/blob/master/net.sourceforge.vrapper.core/src/net/sourceforge/vrapper/vim/register/DefaultRegisterManager.java
307 622 | https://github.com/vrapper/vrapper/blob/master/net.sourceforge.vrapper.eclipse/src/net/sourceforge/vrapper/eclipse/platform/EclipseFileService.java
Best regards
The text was updated successfully, but these errors were encountered: