Fix unlocked TUI visibility and clipboard feedback
This commit is contained in:
@@ -21,7 +21,6 @@ pub struct EntryEditor {
|
||||
buffer: SecretBytes,
|
||||
cursor: usize,
|
||||
input_active: bool,
|
||||
revealed: bool,
|
||||
dirty: bool,
|
||||
}
|
||||
|
||||
@@ -38,7 +37,6 @@ impl EntryEditor {
|
||||
buffer,
|
||||
cursor,
|
||||
input_active: false,
|
||||
revealed: false,
|
||||
dirty: false,
|
||||
}
|
||||
}
|
||||
@@ -77,27 +75,6 @@ impl EntryEditor {
|
||||
|
||||
pub fn end_input(&mut self) {
|
||||
self.input_active = false;
|
||||
self.revealed = false;
|
||||
}
|
||||
|
||||
pub fn is_revealed(&self, id: EntryFieldId) -> bool {
|
||||
self.revealed && self.focused_field().is_some_and(|field| field.id() == id)
|
||||
}
|
||||
|
||||
pub fn reveal_focused(&mut self) -> bool {
|
||||
if self
|
||||
.focused_field()
|
||||
.is_some_and(|field| field.metadata().sensitivity() == EntrySensitivity::Sensitive)
|
||||
{
|
||||
self.revealed = true;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hide_revealed(&mut self) -> bool {
|
||||
std::mem::take(&mut self.revealed)
|
||||
}
|
||||
|
||||
pub fn is_dirty(&self) -> bool {
|
||||
@@ -106,7 +83,6 @@ impl EntryEditor {
|
||||
|
||||
pub fn focus_next(&mut self) -> Result<(), DocumentError> {
|
||||
self.flush()?;
|
||||
self.hide_revealed();
|
||||
if !self.document.fields().is_empty() {
|
||||
self.focused = (self.focused + 1) % self.document.fields().len();
|
||||
self.load_focused();
|
||||
@@ -116,7 +92,6 @@ impl EntryEditor {
|
||||
|
||||
pub fn focus_previous(&mut self) -> Result<(), DocumentError> {
|
||||
self.flush()?;
|
||||
self.hide_revealed();
|
||||
if !self.document.fields().is_empty() {
|
||||
self.focused = self
|
||||
.focused
|
||||
@@ -209,7 +184,6 @@ impl EntryEditor {
|
||||
{
|
||||
self.load_focused();
|
||||
}
|
||||
self.revealed = false;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -319,7 +293,6 @@ impl EntryEditor {
|
||||
|field| SecretBytes::new(field.contents().expose().to_vec()),
|
||||
);
|
||||
self.cursor = self.buffer.expose().len();
|
||||
self.revealed = false;
|
||||
if self.focused_field().is_none() {
|
||||
self.input_active = false;
|
||||
}
|
||||
@@ -348,7 +321,6 @@ impl fmt::Debug for EntryEditor {
|
||||
.field("buffer", &"[REDACTED]")
|
||||
.field("cursor", &self.cursor)
|
||||
.field("input_active", &self.input_active)
|
||||
.field("revealed", &self.revealed)
|
||||
.field("dirty", &self.dirty)
|
||||
.finish()
|
||||
}
|
||||
@@ -386,15 +358,12 @@ mod tests {
|
||||
use crate::viewer::test_support::fixture_document;
|
||||
|
||||
#[test]
|
||||
fn unicode_input_focus_and_masking_are_predictable() {
|
||||
fn unicode_input_and_focus_are_predictable() {
|
||||
let mut editor = EntryEditor::new(fixture_document("unicode/咖啡"));
|
||||
assert!(editor.reveal_focused());
|
||||
editor.begin_input();
|
||||
editor.move_cursor_end();
|
||||
editor.insert_character('界');
|
||||
assert!(editor.is_revealed(editor.focused_field().expect("field").id()));
|
||||
editor.focus_next().expect("focus next");
|
||||
assert!(!editor.revealed);
|
||||
editor.focus_previous().expect("focus previous");
|
||||
assert!(
|
||||
editor
|
||||
|
||||
Reference in New Issue
Block a user