Skip to content

Conversation

@sxyazi
Copy link
Owner

@sxyazi sxyazi commented Apr 24, 2025

An implementation of the feature request: #2671

Closes #2671


With this PR, a new obscure = true option is available:

local value = ya.input {
  title = "Password:",
  obscure = true,
  position = { "center", w = 50 },
}

@sxyazi sxyazi requested a review from Copilot April 24, 2025 23:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements an obscure input component for password entry by introducing an “obscure” flag that toggles between showing the real value and an obscured version. Key changes include updating rendering logic in the Input widget, modifying the data models (InputSnap, InputSnaps, Input) and their constructors to support the new flag, and propagating the flag through configuration and adapter layers.

Reviewed Changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
yazi-widgets/src/input/widget.rs Updated widget render to call display() for obscured input display.
yazi-widgets/src/input/snaps.rs Modified InputSnaps constructors to include the additional obscure flag.
yazi-widgets/src/input/snap.rs Updated InputSnap to track the obscure flag and adjusted offset logic.
yazi-widgets/src/input/input.rs Added an obscure field and updated display() and cursor calculations.
yazi-widgets/src/input/commands/move_.rs Adjusted move logic to consider the obscure masking during calculations.
yazi-plugin/src/utils/layer.rs Propagated the obscure flag from configuration to UI layer elements.
yazi-core/src/mgr/tabs.rs & mgr.rs Removed obsolete active_or functions in favor of cleaner API calls.
yazi-core/src/input/input.rs & commands/show.rs Updated Input instantiation to include the obscure flag from config.
yazi-config/src/popup/options.rs Added the obscure flag to InputCfg and removed the highlight option.
yazi-adapter/src/brand.rs Added a vendor mapping for Warp alongside the other brand key mappings.
Files not reviewed (1)
  • yazi-plugin/preset/plugins/extract.lua: Language not supported
Comments suppressed due to low confidence (3)

yazi-adapter/src/brand.rs:56

  • [nitpick] Ensure the key 'WARP_HONOR_PS1' is correct and consistent with vendor detection naming conventions.
("WARP_HONOR_PS1", B::Warp),

yazi-widgets/src/input/snap.rs:30

  • Initializing 'offset' to 0 instead of usize::MAX changes the starting window calculation; please double-check that this change correctly handles cases when no input has been made yet.
offset: 0,

yazi-widgets/src/input/input.rs:78

  • Verify that the display() method correctly updates the rendered value when the obscure flag is toggled, ensuring consistent behavior with the intended UI design.
pub fn display(&self) -> Cow<str> {

@sxyazi sxyazi merged commit 9e9ebf0 into main Apr 24, 2025
6 checks passed
@sxyazi sxyazi deleted the pr-4ed8bca9 branch April 24, 2025 23:15
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Obscure input component input for inputting passwords

2 participants