mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-08 15:55:15 +01:00
Merge pull request #153027 from microsoft/tyriar/150241
Integration with bash-preexec
This commit is contained in:
@@ -402,7 +402,7 @@ export class CommandDetectionCapability implements ICommandDetectionCapability {
|
||||
}
|
||||
|
||||
this._currentCommand.commandFinishedMarker = this._terminal.registerMarker(0);
|
||||
const command = this._currentCommand.command;
|
||||
let command = this._currentCommand.command;
|
||||
this._logService.debug('CommandDetectionCapability#handleCommandFinished', this._terminal.buffer.active.cursorX, this._currentCommand.commandFinishedMarker?.line, this._currentCommand.command, this._currentCommand);
|
||||
this._exitCode = exitCode;
|
||||
|
||||
@@ -422,6 +422,11 @@ export class CommandDetectionCapability implements ICommandDetectionCapability {
|
||||
return;
|
||||
}
|
||||
|
||||
// When the command finishes and executed never fires the placeholder selector should be used.
|
||||
if (this._exitCode === undefined && command === undefined) {
|
||||
command = '';
|
||||
}
|
||||
|
||||
if ((command !== undefined && !command.startsWith('\\')) || this._handleCommandStartOptions?.ignoreCommandLine) {
|
||||
const buffer = this._terminal.buffer.active;
|
||||
const timestamp = Date.now();
|
||||
|
||||
@@ -118,20 +118,29 @@ __vsc_preexec() {
|
||||
}
|
||||
|
||||
# Debug trapping/preexec inspired by starship (ISC)
|
||||
__vsc_dbg_trap="$(trap -p DEBUG | cut -d' ' -f3 | tr -d \')"
|
||||
if [[ -z "$__vsc_dbg_trap" ]]; then
|
||||
if [[ -n "${bash_preexec_imported:-}" ]]; then
|
||||
__vsc_preexec_only() {
|
||||
__vsc_status="$?"
|
||||
__vsc_preexec
|
||||
}
|
||||
trap '__vsc_preexec_only "$_"' DEBUG
|
||||
elif [[ "$__vsc_dbg_trap" != '__vsc_preexec "$_"' && "$__vsc_dbg_trap" != '__vsc_preexec_all "$_"' ]]; then
|
||||
__vsc_preexec_all() {
|
||||
__vsc_status="$?"
|
||||
builtin eval ${__vsc_dbg_trap}
|
||||
__vsc_preexec
|
||||
}
|
||||
trap '__vsc_preexec_all "$_"' DEBUG
|
||||
precmd_functions+=(__vsc_prompt_cmd)
|
||||
preexec_functions+=(__vsc_preexec_only)
|
||||
else
|
||||
__vsc_dbg_trap="$(trap -p DEBUG | cut -d' ' -f3 | tr -d \')"
|
||||
if [[ -z "$__vsc_dbg_trap" ]]; then
|
||||
__vsc_preexec_only() {
|
||||
__vsc_status="$?"
|
||||
__vsc_preexec
|
||||
}
|
||||
trap '__vsc_preexec_only "$_"' DEBUG
|
||||
elif [[ "$__vsc_dbg_trap" != '__vsc_preexec "$_"' && "$__vsc_dbg_trap" != '__vsc_preexec_all "$_"' ]]; then
|
||||
__vsc_preexec_all() {
|
||||
__vsc_status="$?"
|
||||
builtin eval ${__vsc_dbg_trap}
|
||||
__vsc_preexec
|
||||
}
|
||||
trap '__vsc_preexec_all "$_"' DEBUG
|
||||
fi
|
||||
fi
|
||||
|
||||
__vsc_update_prompt
|
||||
@@ -172,8 +181,10 @@ else
|
||||
__vsc_original_prompt_command=${PROMPT_COMMAND[@]}
|
||||
fi
|
||||
|
||||
if [[ -n "$__vsc_original_prompt_command" && "$__vsc_original_prompt_command" != "__vsc_prompt_cmd" ]]; then
|
||||
PROMPT_COMMAND=__vsc_prompt_cmd_original
|
||||
else
|
||||
PROMPT_COMMAND=__vsc_prompt_cmd
|
||||
if [[ -z "${bash_preexec_imported:-}" ]]; then
|
||||
if [[ -n "$__vsc_original_prompt_command" && "$__vsc_original_prompt_command" != "__vsc_prompt_cmd" ]]; then
|
||||
PROMPT_COMMAND=__vsc_prompt_cmd_original
|
||||
else
|
||||
PROMPT_COMMAND=__vsc_prompt_cmd
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user