Closed swernli closed 1 week ago
@swernli In untitled:Untitled-1
, the :
isn't part of the file name, it's the URL scheme separator (same as the colon in http://foo
). To handle that, I think a better fix would be to update truncate_to_path_separator
so it truncates back to the :
if it can't find a slash. (Bonus: This would handle the technically valid C:foo.qs
Windows path too, though I don't know what kind of crazy use case would land you in that scenario).
I think -
-> _
is a good conversion. I can see how that's necessary for the Untitled file case.
But otherwise, can we keep it very conservative? I'm not as sold on converting spaces. If we open up the door to more filename collisions, it can get confusing IMO. I don't feel too strongly about this last point though.
@swernli In
untitled:Untitled-1
, the:
isn't part of the file name, it's the URL scheme separator (same as the colon inhttp://foo
). To handle that, I think a better fix would be to updatetruncate_to_path_separator
so it truncates back to the:
if it can't find a slash. (Bonus: This would handle the technically validC:foo.qs
Windows path too, though I don't know what kind of crazy use case would land you in that scenario).I think
-
->_
is a good conversion. I can see how that's necessary for the Untitled file case.But otherwise, can we keep it very conservative? I'm not as sold on converting spaces. If we open up the door to more filename collisions, it can get confusing IMO. I don't feel too strongly about this last point though.
I can make the change to truncate_to_path_separator
, thanks for pointing to that! Should I also drop the handling for ` (space) turning into
-`?
I can make the change to
truncate_to_path_separator
, thanks for pointing to that! Should I also drop the handling for` (space) turning into
-`?
I like removing the handling for `, since it isn't an issue in your original scenario -- we should avoid being too liberal with this conversion, and specifically handling your scenario (the
untitled:Untitled-1` situation) is best IMO.
I've updated the logic to only convert -
-> _
which solves the main case I was concerned with. We'll avoid any other special handling until it's necessary.
This change adds some simple logic to clean up unsupported characters from file names before they are used as implicit namespace names. It is by no means exhaustive, but at least takes any
-
replaces them with_
. This will applied for all files, including unsaved ones, so a file saved to disk asMyCool-File.qs
would become the namespaceMyCool_File
and VS Code's somewhat quirky names for new unsaved file buffers likeuntitled:Untitled-1
becomesUntitled_1
. This allows skipping explicit namespaces in unsaved new files, fixes #1582.