Skip to content

Commit

Permalink
complete: suffix a space to non-filenames with "compopt -o filenames"
Browse files Browse the repository at this point in the history
  • Loading branch information
akinomyoga committed Dec 12, 2023
1 parent 7d80167 commit aef8927
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- complete: move face definitions `menu_filter_*` to `core-complete-def.sh` `#D2060` af022266
- make: add `INSDIR_LICENSE` for install location of licenses (reported by willemw) `#D2064` d39998f0 acf3b091
- prompt: show prompt ruler after markers (motivated by U-Labs) `#D2067` e4a90378
- complete: suffix a space to non-filenames with `compopt -o filenames` (reported by Dominiquini) `#D2096` xxxxxxxx

## Fixes

Expand Down
9 changes: 7 additions & 2 deletions lib/core-complete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1780,16 +1780,21 @@ function ble/complete/action:file/initialize.batch {
ble/complete/action/quote-insert.batch
}
function ble/complete/action:file/complete {
ble/complete/action/requote-final-insert

local ret
ble/complete/action:file/.get-filename
if [[ -e $ret || -h $ret ]]; then
if [[ -d $ret ]]; then
ble/complete/action/requote-final-insert
ble/complete/action/complete.mark-directory
else
ble/complete/action:word/complete
fi
else
# Note (#D2096): When "compopt -o filenames" is specified by progcomp, the
# candidates are processed by action:file/complete. However, words that
# are not local filenames can also be generated. Such a word would also
# want to be suffixed by a space.
ble/complete/action:word/complete
fi
}
function ble/complete/action:file/init-menu-item {
Expand Down
13 changes: 13 additions & 0 deletions note.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7092,6 +7092,19 @@ bash_tips

2023-12-12

* complete: suffix a space to non-filenames with compopt -o filenames (reported by Dominiquini) [#D2096]
https://github.com/akinomyoga/ble.sh/issues/378

一番最初の実装 (ce223f73) から action:file/complete はファイル名だけにしか
' ' や '/' は付加していない。その後に progcomp の compopt -o filenames が指
定された時は候補を action:file/complete で処理する様になっていた。変更の歴
史の中でも一時的に「全てに空白をつける」みたいな時期はなかったみたいだ (そ
んな様な気もしたが気の所為か一時的に実験しただけという事だろうか)。

分からないが bash の振る舞いが、compopt -o filenames を指定していたとしても
非ファイル名に対して空白を挿入しているのでそれと同様になる様に修正する。こ
の修正をしただけでちゃんと期待通りに動く様になった。

* keymap/vi: text-object/block.impl を xmap に対応する (requested by Darukutsu) [#D2095]
https://github.com/akinomyoga/ble.sh/issues/377#issuecomment-1850082254

Expand Down

0 comments on commit aef8927

Please sign in to comment.