Skip to content

Copying text like — or é through the system's clipboard program can land garbled while saying it copied #347

Description

@a-team-app

Context

#319 made a copy that Terminal.Gui's clipboard refuses land anyway, through pbcopy, and checks it by reading back through pbpaste. But pbcopy and pbpaste decode and encode text using the locale they're started with. With no UTF-8 locale in the environment (LANG/LC_ALL/LC_CTYPE unset — common under launchd, some SSH sessions and tmux setups), pbcopy stores — as ‚Äî and pbpaste hands back the original bytes, so the read-back matches and TuiCode reports Copied … while the clipboard holds garbled text. That's the exact silent failure #210 set out to end. Pitch: #210.

Reproduced on origin/main (7877e3b):

printf 'a — b §' | env -u LANG -u LC_ALL -u LC_CTYPE pbcopy
osascript -e 'the clipboard'      # a — b §
env -u LANG -u LC_ALL -u LC_CTYPE pbpaste | od -c   # a 342 200 224 b 302 247  (matches the input)

Acceptance criteria

  • With TuiCode started from a shell where LANG, LC_ALL and LC_CTYPE are unset, a copy that falls back to the system's clipboard program and contains non-ASCII text (—, §, é, emoji) pastes in another app exactly as it was in the editor.
  • The same copy with a UTF-8 locale set behaves as it does today.
  • If the text still doesn't arrive intact, the status bar shows Copy failed: … rather than Copied ….

Tests

  • The fallback runs its copy and paste programs with a UTF-8 locale in their environment, whatever TuiCode itself inherited, without dropping the rest of the environment (WAYLAND_DISPLAY, DISPLAY must still reach wl-copy/xclip).
  • Check whether wl-copy/xclip have the same problem and cover them if so; say in the PR what you found.
  • Process invocation stays behind the existing seam, so tests don't spawn real processes.

Out of scope

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-team:devClaimed by the a-team Dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions