Fixing subtle bugs
This commit is contained in:
40
src/app.rs
40
src/app.rs
@@ -53,7 +53,8 @@ impl App {
|
||||
let variables = Arc::new(Mutex::new(HashMap::new()));
|
||||
let dict = Arc::new(Mutex::new(HashMap::new()));
|
||||
let rng = Arc::new(Mutex::new(StdRng::seed_from_u64(0)));
|
||||
let script_engine = ScriptEngine::new(Arc::clone(&variables), Arc::clone(&dict), Arc::clone(&rng));
|
||||
let script_engine =
|
||||
ScriptEngine::new(Arc::clone(&variables), Arc::clone(&dict), Arc::clone(&rng));
|
||||
let live_keys = Arc::new(LiveKeyState::new());
|
||||
|
||||
Self {
|
||||
@@ -251,7 +252,9 @@ impl App {
|
||||
})
|
||||
.collect();
|
||||
self.editor_ctx.editor.set_candidates(candidates);
|
||||
self.editor_ctx.editor.set_completion_enabled(self.ui.show_completion);
|
||||
self.editor_ctx
|
||||
.editor
|
||||
.set_completion_enabled(self.ui.show_completion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +336,8 @@ impl App {
|
||||
{
|
||||
step.command = None;
|
||||
}
|
||||
self.ui.flash(&format!("Script error: {e}"), 300, FlashKind::Error);
|
||||
self.ui
|
||||
.flash(&format!("Script error: {e}"), 300, FlashKind::Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -409,21 +413,14 @@ impl App {
|
||||
let is_playing = snapshot.is_playing(bank, pattern);
|
||||
let pattern_data = self.project_state.project.pattern_at(bank, pattern);
|
||||
|
||||
let existing = self
|
||||
.playback
|
||||
.staged_changes
|
||||
.iter()
|
||||
.position(|c| {
|
||||
c.change.pattern_id().bank == bank && c.change.pattern_id().pattern == pattern
|
||||
});
|
||||
let existing = self.playback.staged_changes.iter().position(|c| {
|
||||
c.change.pattern_id().bank == bank && c.change.pattern_id().pattern == pattern
|
||||
});
|
||||
|
||||
if let Some(idx) = existing {
|
||||
self.playback.staged_changes.remove(idx);
|
||||
self.ui.set_status(format!(
|
||||
"B{:02}:P{:02} unstaged",
|
||||
bank + 1,
|
||||
pattern + 1
|
||||
));
|
||||
self.ui
|
||||
.set_status(format!("B{:02}:P{:02} unstaged", bank + 1, pattern + 1));
|
||||
} else if is_playing {
|
||||
self.playback.staged_changes.push(StagedChange {
|
||||
change: PatternChange::Stop { bank, pattern },
|
||||
@@ -467,7 +464,8 @@ impl App {
|
||||
}
|
||||
let count = self.playback.staged_changes.len();
|
||||
self.playback.staged_changes.clear();
|
||||
self.ui.set_status(format!("Cleared {count} staged changes"));
|
||||
self.ui
|
||||
.set_status(format!("Cleared {count} staged changes"));
|
||||
}
|
||||
|
||||
pub fn select_edit_pattern(&mut self, pattern: usize) {
|
||||
@@ -705,8 +703,11 @@ impl App {
|
||||
}
|
||||
self.project_state.mark_dirty(bank, pattern);
|
||||
self.load_step_to_editor();
|
||||
self.ui
|
||||
.flash(&format!("Linked to step {:02}", copied.step + 1), 150, FlashKind::Success);
|
||||
self.ui.flash(
|
||||
&format!("Linked to step {:02}", copied.step + 1),
|
||||
150,
|
||||
FlashKind::Success,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn harden_step(&mut self) {
|
||||
@@ -896,7 +897,8 @@ impl App {
|
||||
// If current step is a shallow copy, navigate to source step
|
||||
let pattern = &self.project_state.project.banks[self.editor_ctx.bank].patterns
|
||||
[self.editor_ctx.pattern];
|
||||
if let Some(source) = pattern.steps[self.editor_ctx.step].source {
|
||||
if let Some(source) = pattern.step(self.editor_ctx.step).and_then(|s| s.source)
|
||||
{
|
||||
self.editor_ctx.step = source;
|
||||
}
|
||||
self.load_step_to_editor();
|
||||
|
||||
Reference in New Issue
Block a user