Skip to content

Commit 9556e97

Browse files
committed
Yeah, 0 is a control character anyway
1 parent 7bfb8d4 commit 9556e97

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

crates/edit/src/input.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,18 @@ impl<'input> Iterator for Stream<'_, '_, 'input> {
333333
return Some(Input::Text(text));
334334
}
335335
vt::Token::Ctrl(ch) => match ch {
336-
'\0' | '\t' | '\r' => return Some(Input::Keyboard(InputKey::new(ch as u32))),
336+
'\0' => {
337+
// Both Ctrl+Space and Ctrl+Shift+2 produce \0, and
338+
// Ctrl+Space is probably the more common of the two.
339+
return Some(Input::Keyboard(kbmod::CTRL | vk::SPACE));
340+
}
341+
'\t' | '\r' => return Some(Input::Keyboard(InputKey::new(ch as u32))),
337342
'\n' => return Some(Input::Keyboard(kbmod::CTRL | vk::RETURN)),
338343
..='\x1a' => {
339344
// Shift control code to A-Z
340345
let key = ch as u32 | 0x40;
341346
return Some(Input::Keyboard(kbmod::CTRL | InputKey::new(key)));
342347
}
343-
' ' => return Some(Input::Keyboard(kbmod::CTRL | vk::SPACE)),
344348
'\x7f' => return Some(Input::Keyboard(vk::BACK)),
345349
_ => {}
346350
},

crates/edit/src/vt.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,7 @@ impl<'input> Stream<'_, 'input> {
172172
self.parser.state = State::Esc;
173173
self.off += 1;
174174
}
175-
0x00 => {
176-
// Ctrl+Space and Ctrl+Shift+2 both produce ^@, or \0.
177-
self.off += 1;
178-
return Some(Token::Ctrl(' '));
179-
}
180-
c @ (0x01..0x20 | 0x7f) => {
175+
c @ (0x00..0x20 | 0x7f) => {
181176
self.off += 1;
182177
return Some(Token::Ctrl(c as char));
183178
}

0 commit comments

Comments
 (0)