cmderdev/cmder

Question: Alter the Tab key behavior to keep the "/" when typing

DrissBoumlik opened this issue ยท 10 comments

Question

When I type a path and hit the Tab key to autocomplete, it changes the "/" to "\" which causes some issues,
for example, in JavaScript when i run a test using Jest, it doesn't work when the path is typed with "" separator (image 1)
is there a way to change this in a config somewhere, Thank you

image 1 : Not working with "\" separator

image

image 2 : Working with "/" separator

image

Checklist

  • I have read the documentation and made sure what I'm looking for isn't present, or is unclear.
  • I have searched for similar issues, and either this question wasn't asked before, or I didn't find any that describe my question.

https://chrisant996.github.io/clink/clink.html#match_translate_slashes

Set that to off.

clink set match.translate_slashes off

Hello ,
it didn't work with off but with clink set match.translate_slashes slash

Thank you very much

@DrissBoumlik Ah, the off mode got broken by f157793f8d73faedc2624bf6120a735f36bf7344 in the fix for chrisant996/clink#57 back in January, 2021. I'll make a fix so that off doesn't convert slashes that have already been typed.

But, off still wouldn't do what you want, because directory matches append a path separator that matches the OS file system. And you want Unix paths on Windows.

You can use slash, but it will of course have the side effect that now you can't complete Windows file paths anywhere -- they'll all turn into Unix paths, and some non-Unix programs won't recognize Unix paths. (And e.g. starting a path with / can get interpreted as a flag instead of a path.)

I think probably what you really want is something like a auto mode, which finds the first / or \ in the typed path, and then uses that for the rest of the path. So if you typed foo/ it would complete with foo/bar/, or if you typed foo\ it would complete with foo\bar\. However, if there are no / or \ typed yet, then it has to make a choice on its own, and I think it has to default to the system path separator in that case (i.e. \).

Would adding an auto mode like that help?

@chrisant996 I know adding an auto mode would help me, at least ๐Ÿ˜„ Half way through reading your comment I was wondering if there could be a smart setting, which auto would perfectly describe this!

Off topic, could you also implement something that would help with the environment variables, too? I would love it if Clink could keep a track of the env var names that were expanded, then after completion, if would change the value back to the variable. For instance, if I type cd %UserProfile%\Des and hit tab, it would be auto completed to cd %UserProfile%\Desktop rather than cd C:\Users\David\Desktop, which with longer paths would cause some distractions for me.

@chrisant996 I know adding an auto mode would help me, at least ๐Ÿ˜„ Half way through reading your comment I was wondering if there could be a smart setting, which auto would perfectly describe this!

Agreed. I'll probably go with "auto", since that's already the name used in various other Clink settings.

Off topic, could you also implement something that would help with the environment variables, too? I would love it if Clink could keep a track of the env var names that were expanded, then after completion, if would change the value back to the variable. For instance, if I type cd %UserProfile%\Des and hit tab, it would be auto completed to cd %UserProfile%\Desktop rather than cd C:\Users\David\Desktop, which with longer paths would cause some distractions for me.

I've looked into that before. In some simple cases it looks desirable and looks like it would probably be easy to implement. But that's only true in simple cases -- and even in the simple cases it isn't always possible to accurately convert back to environment variables. Such a change would really have to be part of the completion handlers themselves, for them to return non-expanded completions. And that leads to compatibility problems, and makes it much more complicated for users to write their own completion handlers, and so on.

Unfortunately I haven't found a way to do that both accurately and reliably. And if it isn't both accurate and reliable, then it'll just create a bunch of complaints and cost users and myself wasted time.

Sorry!

@chrisant996 Yes definitely , an auto option would be amazing, and I think many would love it

I've also added a new command to toggle the slash type in the word at the cursor, bound to Ctrl-/ by default.

I expect to publish the Clink update later tonight.

Clink v1.6.16 is available with the auto mode for the match.translate_slashes setting (and auto is the default now), and with Ctrl-/ to toggle slashes in the word at the cursor.

@DrissBoumlik Please type clink update into Cmder and let Clink update. Then make sure match.translate_slashes is set to auto and test the feature. If you're satisfied, we can close this issue.

@chrisant996 Thanks for the new feature!

@DRSDavidSoft already did, just checked the auto option, great work, ๐ŸŽŠ

@chrisant996 Thank you very much indeed ๐Ÿฅ‡