diff --git a/src/phpDebug.ts b/src/phpDebug.ts index 4db8d584..86fc0b90 100644 --- a/src/phpDebug.ts +++ b/src/phpDebug.ts @@ -318,6 +318,10 @@ class PhpDebugSession extends vscode.DebugSession { }) connection.on('error', disposeConnection) connection.on('close', disposeConnection) + connection.on('before-execute-command', () => { + // It is about to start executing PHP code + this.sendEvent(new vscode.ContinuedEvent(connection.id)) + }) await connection.waitForInitPacket() // override features from launch.json diff --git a/src/xdebugConnection.ts b/src/xdebugConnection.ts index 246e0b8f..91dc4b86 100644 --- a/src/xdebugConnection.ts +++ b/src/xdebugConnection.ts @@ -640,6 +640,15 @@ export class Connection extends DbgpConnection { }) } + /** Adds the given command to the queue, or executes immediately if no commands are currently being processed. */ + private _enqueue(command: Command): void { + if (this._commandQueue.length === 0 && this._pendingCommands.size === 0) { + this._executeCommand(command) + } else { + this._commandQueue.push(command) + } + } + /** * Pushes a new execute command (one that results in executing PHP code) to the queue that will be executed after all the previous * commands have finished and we received a response. @@ -679,6 +688,11 @@ export class Connection extends DbgpConnection { const data = iconv.encode(commandString, ENCODING) this._pendingCommands.set(transactionId, command) this._pendingExecuteCommand = command.isExecuteCommand + if (this._pendingExecuteCommand) { + // Since PHP execution commands block anything on the connection until it is + // done executing, emit that the connection is about to go into such a locked state + this.emit('before-execute-command') + } await this.write(data) }