The problem isn't in $did(), it's in the way you're storing what it's returning. mIRC variables will have spaces trimmed from the end of them so when you add a line to the %full variable which has a space on the end it's being stripped and it's as if the space never existed. The solution comes from the fact that spaces are not stripped fromt the
beginning of a variable, so you must construct it in reverse. Use this code instead and you'll get the correct text:
on *:dialog:example:sclick:2:{
var %i = $did($dname, 1).lines
while %i {
echo -a $did($dname, 1, %i)
var %full = $did($dname, 1, %i) $+ %full
dec %i
}
echo -a Reconstructed: %full
}