zsh-workers
 help / color / mirror / code / Atom feed
* Path to fix copy-earlier-word handling of numeric arguments
@ 2024-04-04  9:39 Huy Z
  2024-04-04 10:03 ` Mikael Magnusson
  0 siblings, 1 reply; 3+ messages in thread
From: Huy Z @ 2024-04-04  9:39 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]

As initially submitted at https://github.com/zsh-users/zsh/pull/116 :

------------------------------------------------------------------------

As mentioned in the code comment:

   # 1 means last word, 2 second last, etc.

the numeric argument is supposed to be interpreted as an offset from the 
end.

The intended behavior is a lot more useful than the current behavior.


------------------------------------------------------------------------



diff --git a/Functions/Zle/copy-earlier-word 
b/Functions/Zle/copy-earlier-word
index 90e862da3..1262c0c82 100644
--- a/Functions/Zle/copy-earlier-word
+++ b/Functions/Zle/copy-earlier-word
@@ -11,7 +11,7 @@ setopt typesetsilent
  typeset -g __copyword
  if (( ${NUMERIC:-0} )); then
    # 1 means last word, 2 second last, etc.
-  (( __copyword = ${NUMERIC:-0} ))
+  (( __copyword = -${NUMERIC:-0} ))
    zstyle -s :$WIDGET widget __copywidget
  elif [[ -n $__copyword && $WIDGET = $LASTWIDGET ]]; then
    (( __copyword-- ))

------------------------------------------------------------------------


[-- Attachment #2: Type: text/html, Size: 7119 bytes --]

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

end of thread, other threads:[~2024-04-04 10:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-04  9:39 Path to fix copy-earlier-word handling of numeric arguments Huy Z
2024-04-04 10:03 ` Mikael Magnusson
2024-04-04 10:10   ` Mikael Magnusson

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).