zsh-workers
 help / color / mirror / code / Atom feed
* [BUG] Line number in prompt after `zle reset-prompt'
@ 2015-10-31 18:42 Sebastian Gniazdowski
  2015-10-31 20:23 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Gniazdowski @ 2015-10-31 18:42 UTC (permalink / raw)
  To: Zsh hackers list

Hello
To reproduce:

PROMPT="%i # "
a() { zle reset-prompt }
zle -N a
bindkey "^E" a

and press Ctrl-E. Line number will change, most probably to "0", but
in my other large script it changes to 50 and other numbers, depending
on what I do with the script

Best regards,
Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] Line number in prompt after `zle reset-prompt'
  2015-10-31 18:42 [BUG] Line number in prompt after `zle reset-prompt' Sebastian Gniazdowski
@ 2015-10-31 20:23 ` Bart Schaefer
  2015-11-01 15:18   ` Sebastian Gniazdowski
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2015-10-31 20:23 UTC (permalink / raw)
  To: Zsh hackers list

On Oct 31,  7:42pm, Sebastian Gniazdowski wrote:
}
} PROMPT="%i # "
} a() { zle reset-prompt }
} zle -N a
} bindkey "^E" a
} 
} and press Ctrl-E. Line number will change

Not sure this is a bug:

%N
     The name of the script, sourced file, or shell function that zsh is
     currently executing, whichever was started most recently.

%i
     The line number currently being executed in the script, sourced
     file, or shell function given by %N.

If you use:

    PROMPT="%N %i # "

and then press ^E, you will see

    a 0 # 

which is correct, the line number in the function "a" is 0.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] Line number in prompt after `zle reset-prompt'
  2015-10-31 20:23 ` Bart Schaefer
@ 2015-11-01 15:18   ` Sebastian Gniazdowski
  2015-11-01 18:59     ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Gniazdowski @ 2015-11-01 15:18 UTC (permalink / raw)
  To: Zsh hackers list

I would say it's not a bug. I found it possible to replace
"reset-prompt" with "redisplay" which doesn't re-expand prompt.
However, there is one interesting thing:

PROMPT=" %i # "
a() { zle redisplay }
zle -N a
b() { zle redisplay; zle -M "test" }
zle -N b
c() { zle -M "test" }
zle -N c
bindkey "^E" a
bindkey "^R" b
bindkey "^T" c

"a" and "c" will not reexpand prompt, while "b" will, apparently with no reason

Best regards,
Sebastian Gniazdowski


On 31 October 2015 at 21:23, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Oct 31,  7:42pm, Sebastian Gniazdowski wrote:
> }
> } PROMPT="%i # "
> } a() { zle reset-prompt }
> } zle -N a
> } bindkey "^E" a
> }
> } and press Ctrl-E. Line number will change
>
> Not sure this is a bug:
>
> %N
>      The name of the script, sourced file, or shell function that zsh is
>      currently executing, whichever was started most recently.
>
> %i
>      The line number currently being executed in the script, sourced
>      file, or shell function given by %N.
>
> If you use:
>
>     PROMPT="%N %i # "
>
> and then press ^E, you will see
>
>     a 0 #
>
> which is correct, the line number in the function "a" is 0.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] Line number in prompt after `zle reset-prompt'
  2015-11-01 15:18   ` Sebastian Gniazdowski
@ 2015-11-01 18:59     ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2015-11-01 18:59 UTC (permalink / raw)
  To: Zsh hackers list

On Nov 1,  4:18pm, Sebastian Gniazdowski wrote:
}
} a() { zle redisplay }
} b() { zle redisplay; zle -M "test" }
} c() { zle -M "test" }
} 
} "a" and "c" will not reexpand prompt, while "b" will, apparently with
} no reason

Each of redisplay and -M is setting a different flag indicating that
a part of the prompt, buffer, and "status line" needs to be redrawn.
Only when both of the of those flags are set is the display considered
to be in a sufficiently indeterminate state that the whole thing needs
to be regenerated.

(If you reverse "zle -M" + "zle redisplay" the prompt will start to
climb up the screen and the -M text will never appear, because those
two flags are now being considered in the wrong order.)

Ultimately this is because ZLE does not attempt to do "full screen"
management of the display, i.e., it does not maintain a full internal
mapping of the display to minimize updates; it only tracks horizontal
positions where the prompt starts and ends, and number of lines used
by the prompt and the buffer.  So it will do a complete repaint in
some circumstances that might seem unnecessary.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-01 18:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-31 18:42 [BUG] Line number in prompt after `zle reset-prompt' Sebastian Gniazdowski
2015-10-31 20:23 ` Bart Schaefer
2015-11-01 15:18   ` Sebastian Gniazdowski
2015-11-01 18:59     ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).