Skip to content

Commit 4e466e9

Browse files
fix
1 parent 7518edf commit 4e466e9

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

codex-rs/tui/src/bottom_pane/textarea.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,9 @@ impl TextArea {
687687
.iter()
688688
.position(|e| e.id.as_deref() == Some(id))
689689
{
690-
let start = self.elements[elem_idx].range.start;
691690
let old_range = self.elements[elem_idx].range.clone();
692-
self.replace_range_raw(old_range.clone(), text);
691+
let start = old_range.start;
692+
self.replace_range_raw(old_range, text);
693693
// After replace_range_raw, the old element entry was removed if fully overlapped.
694694
// Re-add an updated element with the same id and new range.
695695
let new_end = start + text.len();

codex-rs/tui/src/voice.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,14 @@ fn build_input_stream(
169169
data: Arc<Mutex<Vec<i16>>>,
170170
last_peak: Arc<AtomicU16>,
171171
) -> Result<cpal::Stream, String> {
172-
let data_cb = data.clone();
173-
let last_peak_cb = last_peak.clone();
174172
match config.sample_format() {
175173
cpal::SampleFormat::F32 => device
176174
.build_input_stream(
177175
&config.clone().into(),
178176
move |input: &[f32], _| {
179177
let peak = peak_f32(input);
180-
last_peak_cb.store(peak, Ordering::Relaxed);
181-
if let Ok(mut buf) = data_cb.lock() {
178+
last_peak.store(peak, Ordering::Relaxed);
179+
if let Ok(mut buf) = data.lock() {
182180
for &s in input {
183181
buf.push(f32_to_i16(s));
184182
}
@@ -193,8 +191,8 @@ fn build_input_stream(
193191
&config.clone().into(),
194192
move |input: &[i16], _| {
195193
let peak = peak_i16(input);
196-
last_peak_cb.store(peak, Ordering::Relaxed);
197-
if let Ok(mut buf) = data_cb.lock() {
194+
last_peak.store(peak, Ordering::Relaxed);
195+
if let Ok(mut buf) = data.lock() {
198196
buf.extend_from_slice(input);
199197
}
200198
},
@@ -206,9 +204,9 @@ fn build_input_stream(
206204
.build_input_stream(
207205
&config.clone().into(),
208206
move |input: &[u16], _| {
209-
if let Ok(mut buf) = data_cb.lock() {
207+
if let Ok(mut buf) = data.lock() {
210208
let peak = convert_u16_to_i16_and_peak(input, &mut buf);
211-
last_peak_cb.store(peak, Ordering::Relaxed);
209+
last_peak.store(peak, Ordering::Relaxed);
212210
}
213211
},
214212
move |err| error!("audio input error: {err}"),

0 commit comments

Comments
 (0)