Don't use the type name as the name of a variable

This commit is contained in:
Timothy Warren 2019-09-09 13:16:56 -04:00
parent e720de0eb8
commit 788edf7e03

View File

@ -637,7 +637,7 @@ impl Editor {
Keyword1 => 33, // Yellow Keyword1 => 33, // Yellow
Keyword2 => 32, // Green Keyword2 => 32, // Green
LineComment => 36, // Cyan LineComment => 36, // Cyan
MultiLineComment => 36, MultiLineComment => 36, // Cyan
Normal => 37, Normal => 37,
Number => 31, // Red Number => 31, // Red
SearchMatch => 34, // Blue SearchMatch => 34, // Blue
@ -699,10 +699,10 @@ impl Editor {
self.set_status_message(&format!("{} {}", prompt, buffer)); self.set_status_message(&format!("{} {}", prompt, buffer));
self.refresh_screen(); self.refresh_screen();
let char = self.read_key(); let ch = self.read_key();
if char.is_some() { if ch.is_some() {
let char = char.unwrap(); let ch = ch.unwrap();
match char { match ch {
Backspace => { Backspace => {
buffer.pop(); buffer.pop();
} }
@ -711,13 +711,13 @@ impl Editor {
} }
Escape => { Escape => {
self.set_status_message(""); self.set_status_message("");
cb(self, &String::from(""), char); cb(self, &String::from(""), ch);
return String::from(""); return String::from("");
} }
Enter => { Enter => {
if buffer.len() != 0 { if buffer.len() != 0 {
self.set_status_message(""); self.set_status_message("");
cb(self, &buffer, char); cb(self, &buffer, ch);
return buffer; return buffer;
} }
} }
@ -730,7 +730,7 @@ impl Editor {
_ => (), _ => (),
}; };
cb(self, &buffer, char); cb(self, &buffer, ch);
} }
} }
} }
@ -790,9 +790,9 @@ impl Editor {
pub fn process_keypress(&mut self) -> Option<KeyCode<char>> { pub fn process_keypress(&mut self) -> Option<KeyCode<char>> {
let key = self.read_key(); let key = self.read_key();
if key.is_some() { if key.is_some() {
let char = key.unwrap(); let ch = key.unwrap();
match char { match ch {
Backspace => self._del_or_backspace(Backspace), Backspace => self._del_or_backspace(Backspace),
DeleteKey => self._del_or_backspace(DeleteKey), DeleteKey => self._del_or_backspace(DeleteKey),
Enter => self.insert_new_line(), Enter => self.insert_new_line(),
@ -1106,8 +1106,8 @@ impl Editor {
let mut rx: usize = 0; let mut rx: usize = 0;
let mut i: usize = 0; let mut i: usize = 0;
for char in self.rows[index].chars.chars() { for ch in self.rows[index].chars.chars() {
if char == '\t' { if ch == '\t' {
rx += (KILO_TAB_STOP - 1) - (rx % KILO_TAB_STOP); rx += (KILO_TAB_STOP - 1) - (rx % KILO_TAB_STOP);
} else { } else {
rx += 1; rx += 1;
@ -1127,8 +1127,8 @@ impl Editor {
let mut current_rx: usize = 0; let mut current_rx: usize = 0;
let mut cx: usize = 0; let mut cx: usize = 0;
for char in self.rows[index].chars.chars() { for ch in self.rows[index].chars.chars() {
if char == '\t' { if ch == '\t' {
current_rx += (KILO_TAB_STOP - 1) - (current_rx % KILO_TAB_STOP); current_rx += (KILO_TAB_STOP - 1) - (current_rx % KILO_TAB_STOP);
} else { } else {
current_rx += 1; current_rx += 1;