clamp i value
This commit is contained in:
parent
2de84801bd
commit
00936f60f1
@ -28,7 +28,9 @@ lto = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
eframe = { git = "https://github.com/Titaniumtown/egui.git", default-features = false }
|
eframe = { git = "https://github.com/Titaniumtown/egui.git", default-features = false }
|
||||||
shadow-rs = { version = "0.11.0", default-features = false }
|
shadow-rs = { version = "0.11.0", default-features = false }
|
||||||
const_format = { version = "0.2.22", default-features = false, features = ["fmt"] }
|
const_format = { version = "0.2.22", default-features = false, features = [
|
||||||
|
"fmt",
|
||||||
|
] }
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
exmex = { git = "https://github.com/bertiqwerty/exmex.git", branch = "main", features = [
|
exmex = { git = "https://github.com/bertiqwerty/exmex.git", branch = "main", features = [
|
||||||
"partial",
|
"partial",
|
||||||
@ -59,6 +61,8 @@ async-lock = { git = "https://github.com/smol-rs/async-lock.git", optional = tru
|
|||||||
instant = { version = "0.1.12", features = ["wasm-bindgen"] }
|
instant = { version = "0.1.12", features = ["wasm-bindgen"] }
|
||||||
console_error_panic_hook = "0.1.7"
|
console_error_panic_hook = "0.1.7"
|
||||||
wee_alloc = "0.4.5"
|
wee_alloc = "0.4.5"
|
||||||
wasm-bindgen = { version = "0.2.80", default-features = false, features = ["std"] }
|
wasm-bindgen = { version = "0.2.80", default-features = false, features = [
|
||||||
|
"std",
|
||||||
|
] }
|
||||||
web-sys = "0.3.57"
|
web-sys = "0.3.57"
|
||||||
tracing-wasm = "0.2.1"
|
tracing-wasm = "0.2.1"
|
||||||
|
|||||||
@ -54,24 +54,13 @@ impl<'a> AutoComplete<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let max_i = hints.len() as i16 - 1;
|
let max_i = hints.len() as i16 - 1;
|
||||||
let mut i = self.i as i16;
|
|
||||||
|
|
||||||
match movement {
|
self.i = match movement {
|
||||||
Movement::Up => {
|
Movement::Up => self.i as i16 - 1,
|
||||||
i -= 1;
|
Movement::Down => self.i as i16 + 1,
|
||||||
if 0 > i {
|
_ => self.i as i16,
|
||||||
i = max_i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Movement::Down => {
|
|
||||||
i += 1;
|
|
||||||
if i > max_i {
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
self.i = i as usize;
|
.clamp(0, max_i) as usize;
|
||||||
}
|
}
|
||||||
HintEnum::Single(hint) => {
|
HintEnum::Single(hint) => {
|
||||||
if movement == &Movement::Complete {
|
if movement == &Movement::Complete {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user