Skip to content

Commit

Permalink
fix(jupyter): fix panics for overslow subtraction (#26371)
Browse files Browse the repository at this point in the history
I don't have a reliable reproduction for it, but it makes it
painful to use the Jupyter kernel with semi-frequent random panics.

The completions don't always work correctly anyway, so I think
it's better to just not panic here for the time being.

Fixes #26340
  • Loading branch information
bartlomieju committed Oct 17, 2024
1 parent 2c0cc4e commit d1be72b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cli/tools/jupyter/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,12 @@ impl JupyterServer {
})
.collect();

(candidates, cursor_pos - prop_name.len())
if prop_name.len() > cursor_pos {
// TODO(bartlomieju): most likely not correct, but better than panicking because of sub with overflow
(candidates, cursor_pos)
} else {
(candidates, cursor_pos - prop_name.len())
}
} else {
// combine results of declarations and globalThis properties
let mut candidates = get_expression_property_names(
Expand All @@ -349,7 +354,12 @@ impl JupyterServer {
candidates.sort();
candidates.dedup(); // make sure to sort first

(candidates, cursor_pos - expr.len())
if expr.len() > cursor_pos {
// TODO(bartlomieju): most likely not correct, but better than panicking because of sub with overflow
(candidates, cursor_pos)
} else {
(candidates, cursor_pos - expr.len())
}
};

connection
Expand Down

0 comments on commit d1be72b

Please sign in to comment.