Shell integration is messed up with starship prompt

Bug report

Thanks for filing an issue! Please answer the questions below so I can help you.

  • iTerm2 version: 3.4.16

  • OS version: 12.4

  • Attach ~/Library/Preferences/com.googlecode.iterm2.plist here (drag-drop from finder into this window) com.googlecode.iterm2.plist

  • Attach a debug log, if possible. debuglog.txt

  • Attach a screen capture video if it would make the reproduction steps clearer.

PLEASE ATTACH YOUR PLIST FILE FOR BUG REPORTS! Seriously! I'll probably ask you for it if you don’t.

Detailed steps to reproduce the problem

  1. Use the following configuration of Zsh and Starship prompt:

    .zshrc:

    eval "$(starship init zsh)"
    ITERM2_SQUELCH_MARK=1
    test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"

    starship.toml:

    "$schema" = 'https://starship.rs/config-schema.json'
    
    format = "$all${custom.iterm_prompt_marker}$character"
    
    [custom.iterm_prompt_marker]
    when = '[ "$TERM_PROGRAM" = "iTerm.app" ]'
    format = "\u001b\\]133;A\u0007"
  2. Type anything into the shell.

What happened

The prompt character printed by Starship gets erased when you type the second character.

What should have happened

The prompt should behave as normally when shell integration isn't enabled.