From 788edf7e03f732db69765dd5b5a4e885dcde21a6 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 9 Sep 2019 13:16:56 -0400 Subject: [PATCH] Don't use the type name as the name of a variable --- src/editor.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index ce3ec8a..e192034 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -637,7 +637,7 @@ impl Editor { Keyword1 => 33, // Yellow Keyword2 => 32, // Green LineComment => 36, // Cyan - MultiLineComment => 36, + MultiLineComment => 36, // Cyan Normal => 37, Number => 31, // Red SearchMatch => 34, // Blue @@ -699,10 +699,10 @@ impl Editor { self.set_status_message(&format!("{} {}", prompt, buffer)); self.refresh_screen(); - let char = self.read_key(); - if char.is_some() { - let char = char.unwrap(); - match char { + let ch = self.read_key(); + if ch.is_some() { + let ch = ch.unwrap(); + match ch { Backspace => { buffer.pop(); } @@ -711,13 +711,13 @@ impl Editor { } Escape => { self.set_status_message(""); - cb(self, &String::from(""), char); + cb(self, &String::from(""), ch); return String::from(""); } Enter => { if buffer.len() != 0 { self.set_status_message(""); - cb(self, &buffer, char); + cb(self, &buffer, ch); 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> { let key = self.read_key(); if key.is_some() { - let char = key.unwrap(); + let ch = key.unwrap(); - match char { + match ch { Backspace => self._del_or_backspace(Backspace), DeleteKey => self._del_or_backspace(DeleteKey), Enter => self.insert_new_line(), @@ -1106,8 +1106,8 @@ impl Editor { let mut rx: usize = 0; let mut i: usize = 0; - for char in self.rows[index].chars.chars() { - if char == '\t' { + for ch in self.rows[index].chars.chars() { + if ch == '\t' { rx += (KILO_TAB_STOP - 1) - (rx % KILO_TAB_STOP); } else { rx += 1; @@ -1127,8 +1127,8 @@ impl Editor { let mut current_rx: usize = 0; let mut cx: usize = 0; - for char in self.rows[index].chars.chars() { - if char == '\t' { + for ch in self.rows[index].chars.chars() { + if ch == '\t' { current_rx += (KILO_TAB_STOP - 1) - (current_rx % KILO_TAB_STOP); } else { current_rx += 1;