unix-paste-bug

Open Beginner friendly
#2,360 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Domain
cli

Research direction

Start in lem/frontends/ncurses/clipboard.lisp and inspect *unix-paste-commands* and the WSL paste-aux method mentioned in the issue. Check how wl-paste output and the WSL trailing newline are handled, then run the clipboard-related tests if available. Done means pasting no longer adds an unwanted tail while legitimate pasted text remains intact.

Written by the indexing model from the issue text.

Description

Phenomenon:When build both webview and ncurses ,pasting text will add a #\Newline tail in pasted text。

Reason :wl-paste default output adds #\Newline which called in lem/frontends/ncurses/clipboard.lisp using unix-paste-commands。
Repair suggestion:
change

(defparameter *unix-paste-commands*
  '(("wl-paste" "--no-newline")
    ("xsel" "--output" "--clipboard")
    ("xclip" "-out" "-selection" "clipboard")))

to

(defparameter *unix-paste-commands*
  '(("wl-paste")
    ("xsel" "--output" "--clipboard")
    ("xclip" "-out" "-selection" "clipboard")))

There's code which perhaps want to fix this bug in WSL。

(when (and (plusp (length text))
           (char= #\newline (char text (1- (length text)))))
  (setf text (subseq text 0 (1- (length text)))))

in

(defmethod paste-aux ((os wsl))
  (let ((text (execute-paste '("powershell.exe" "Get-Clipboard"))))
    (setf text (ppcre:regex-replace-all "\\r" text ""))
    (when (and (plusp (length text))
               (char= #\newline (char text (1- (length text)))))
      (setf text (subseq text 0 (1- (length text)))))
    text))

I think it need to be deleted。

Dominant language
Common Lisp
Stars
3.1k
Forks
261
Avg merge
1d 1h
Merged PRs (30d)
117

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lem-project/lem

All issues in lem-project/lem

Similar issues

More CLI issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.