mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix(jupyter): fix panics for overslow subtraction (#26371)
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 https://github.com/denoland/deno/issues/26340
This commit is contained in:
parent
50724d014a
commit
02e5a7a012
1 changed files with 12 additions and 2 deletions
|
@ -329,7 +329,12 @@ impl JupyterServer {
|
||||||
})
|
})
|
||||||
.collect();
|
.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 {
|
} else {
|
||||||
// combine results of declarations and globalThis properties
|
// combine results of declarations and globalThis properties
|
||||||
let mut candidates = get_expression_property_names(
|
let mut candidates = get_expression_property_names(
|
||||||
|
@ -349,7 +354,12 @@ impl JupyterServer {
|
||||||
candidates.sort();
|
candidates.sort();
|
||||||
candidates.dedup(); // make sure to sort first
|
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
|
connection
|
||||||
|
|
Loading…
Reference in a new issue