mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix(kernel): Do not increase counter if store_history=false (#20848)
Fixes https://github.com/denoland/deno/issues/20847 Co-authored-by: Nathan Whitaker <nathan@deno.com>
This commit is contained in:
parent
a2a537e196
commit
9841d3fdf1
3 changed files with 39 additions and 1 deletions
|
@ -160,6 +160,14 @@ impl JupyterMessage {
|
||||||
self.header["msg_type"].as_str().unwrap_or("")
|
self.header["msg_type"].as_str().unwrap_or("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn store_history(&self) -> bool {
|
||||||
|
self.content["store_history"].as_bool().unwrap_or(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn silent(&self) -> bool {
|
||||||
|
self.content["silent"].as_bool().unwrap_or(false)
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn code(&self) -> &str {
|
pub(crate) fn code(&self) -> &str {
|
||||||
self.content["code"].as_str().unwrap_or("")
|
self.content["code"].as_str().unwrap_or("")
|
||||||
}
|
}
|
||||||
|
|
|
@ -341,7 +341,9 @@ impl JupyterServer {
|
||||||
msg: JupyterMessage,
|
msg: JupyterMessage,
|
||||||
connection: &mut Connection<zeromq::RouterSocket>,
|
connection: &mut Connection<zeromq::RouterSocket>,
|
||||||
) -> Result<(), AnyError> {
|
) -> Result<(), AnyError> {
|
||||||
self.execution_count += 1;
|
if !msg.silent() && msg.store_history() {
|
||||||
|
self.execution_count += 1;
|
||||||
|
}
|
||||||
*self.last_execution_request.borrow_mut() = Some(msg.clone());
|
*self.last_execution_request.borrow_mut() = Some(msg.clone());
|
||||||
|
|
||||||
msg
|
msg
|
||||||
|
|
|
@ -533,3 +533,31 @@ async fn jupyter_execute_request() -> Result<()> {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn jupyter_store_history_false() -> Result<()> {
|
||||||
|
let (_ctx, client, _process) = setup().await;
|
||||||
|
client
|
||||||
|
.send(
|
||||||
|
Shell,
|
||||||
|
"execute_request",
|
||||||
|
json!({
|
||||||
|
"silent": false,
|
||||||
|
"store_history": false,
|
||||||
|
"code": "console.log(\"asdf\")"
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let reply = client.recv(Shell).await?;
|
||||||
|
assert_eq!(reply.header.msg_type, "execute_reply");
|
||||||
|
assert_eq_subset(
|
||||||
|
reply.content,
|
||||||
|
json!({
|
||||||
|
"status": "ok",
|
||||||
|
"execution_count": 0,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue