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

Re: promptsubst and empty variables



On Sep 14, 11:24am, Frank Terbeck wrote:
}
} I am seeing some weirdness using prompt_subst and empty variables in
} RPS1 (from zsh -f):
} 
} [snip]
} setopt promptsubst
} RPROMPT='${foo}'

I get the misplaced cursor right here; there doesn't need to be a value
assigned to PROMPT with or without a substitution in it.

} This results in the following cursor position:
} 
} ~%_
}   ^- At the underscore, that's where the cursor is. Note, the missing
}      trailing space.
} 
}     + it is in every version starting from 3.1.6 except:
}         - 4.3.1 and 4.3.2
}         - it's back in 4.3.3 and remains to be in the CVS HEAD
}           version.

I can't follow how any of the 4.3.0->4.3.1 changes could have affected
this, but anyway ...

The problem is that singsub() called from promptexpand() is returning
nulstring, which is the Nularg token followed by a NUL byte.

This is incorrectly being interpreted by promptexpand() as a so-called
"glitch" space passed down from the caller, and is therefore counted
as one space in the width of the prompt.

Unfortunately having learned this much, I have very little idea how to
proceed with fixing it.  One possibility might be to do a first pass
over the string counting and removing all "glitches" before making the
call to singsub(), so that Nularg introduced by substitution could be
ignored in a second pass.  Another might be to introduce a real token
for the "glitch" space rather than overloading Nularg, but that may
have pretty wide-ranging ramifications.

Wayne, this is mostly your baby.  What to do?



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