Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bug with camel case and delete-whole-word-match function



On Sun, 24 Jul 2016 01:06:02 +0200
Oliver Kiddle <okiddle@xxxxxxxxxxx> wrote:
> One is that if the cursor is in the middle of a block of whitespace
> at the end of the line, the 4th element (whitespace after cursor)
> is empty while element 7 contains the whitespace.
> A similar issue occurs at the start of the line - element 1 contains
> whitespace while element 3 doesn't.

I'm not sure what you're testing.  I've put a test function below and
ran it with

mwbs-test -w normal-subword $'one two ThreeFour ' $' \nFiveSix seven'

and I get

      start: 'one two Three'
wd-before-c: 'Four'
ws-before-c: ' '
 ws-after-c: ' 
'
 wd-after-c: 'Five'
 ws-after-w: ''
        end: 'Six seven'

which is what I expect.  Similarly at the start of the next line.  Do
you get something different, or isn't it testing for the problem at all?

> The other issue is that with the shell word style, it'll put whitespace
> at the end of element 5 instead of in element 6.

Aagain, I get:

mwbs-test -w shell $'one two ThreeFour \n ' $' FiveSix seven'

      start: 'one two '
wd-before-c: 'ThreeFour'
ws-before-c: ' 
 '
 ws-after-c: ' '
 wd-after-c: 'FiveSix'
 ws-after-w: ' '
        end: 'seven'

pws


# mwbs-test
autoload -Uz match-words-by-style

local wordstyle=normal-subword
local opt
while getopts "w:" opt; do
  case $opt in
    (w)
    wordstyle=$OPTARG
    ;;
    (*)
    return 1
    ;;
  esac
done
shift $(( OPTIND - 1 ))

if (( $# != 2 )); then
  print "Usage: mwbs-test LBUFFER RBUFFER" >&2
  return 1
fi

local -a matched_words

local LBUFFER=$1 RBUFFER=$2

match-words-by-style -w $wordstyle || return

print -r "\
      start: '$matched_words[1]'
wd-before-c: '$matched_words[2]'
ws-before-c: '$matched_words[3]'
 ws-after-c: '$matched_words[4]'
 wd-after-c: '$matched_words[5]'
 ws-after-w: '$matched_words[6]'
        end: '$matched_words[7]'
"



Messages sorted by: Reverse Date, Date, Thread, Author