[Completion] apply compadd replacements during prefix replacement in _canonical_paths (for umount
)
#86
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
NB: marked as draft because a) the comment needs to be cleaned up but also because b) this is merely parts of the file copied together, i don't see a more elegant way right now, but suspect maintainers will either know which way to go, or have reservations against merging how i copied it together. In any case this is related to an issue (see below) and I went ahead to with patching it up for my local usage.
issue
USB sticks can have white spaces in their device names (might be used on windows, they get handed around, so whoever mounts them might not be whoever named it). In my case a stick I used was just called "USB DISK". The stick gets automounted (by udiskie, but i suspect it's common to auto mount USB sticks and use the device name) to
/media/pseyfert/USB DISK
.When tab completing
umount ⇥
from anywhere the tab completions contain correctly/media/pseyfert/USB\ DISK
(that is, the white space gets escaped. When changing to/media/pseyfert
, the completions forumount
still contain the mount point with absolute path, but in addition the relative pathUSB DISK
(this time, it gets entered like that, without escaping the white space).my change
I traced down that
umount
gets completed by_mount
which calls_umountable
which calls_canonical_paths
and in there, there is theif
which detects if prefix replacement should happen. in case of umount,files
contains the mount points without escape symbols, the "then" applies various replacements (as specified by _umountable) and escapes the white space. The else does prefix replacment but does not do (as indicated by the comment) the-M
replacement. The-M
replacement is (I think) irrelevant for me here, butcompadd
in the "then" also takes care of escaping white spaces.