Skip to content

bash hook: nothing is captured with VS Code's shell integration loaded after it #52

Open

Description

@NaNIsaac

With VS Code's bash shell integration loaded after the codigest hook (VS Code sources it after ~/.bashrc), no command is captured.

Cause: VS Code chains an existing DEBUG trap but runs it only for the first DEBUG event of each command line (__vsc_preexec_all, guarded by __vsc_in_command_execution). bash also runs the DEBUG trap for a bind -x handler, and the hook marks the line with one (__cdg_mark on Enter). That first event is the handler, before __cdg_mark has opened the capture, so __cdg_debug never sees the command itself and the capture never starts. VS Code's own preexec also fires at the handler instead of the command.

To reproduce: in an interactive bash --norc -i with cdg on PATH, source src/codigest/shell/hook.sh, then VS Code's script (code --locate-shell-integration-path bash), then run any command: it is not captured. tests/test_hook_terminal.py::test_bash_vscode_integration_sees_the_typed_line shows it.

Possible fixes: start the capture without relying on the next DEBUG event once a line is marked, or let the Enter handler leave other preexec frameworks' state as it found it. bash-preexec ignores bind -x handlers, so the same conflict may not appear there; not checked.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions