-
Notifications
You must be signed in to change notification settings - Fork 9
Filter blank lines in apt generator callbacks #378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,10 +16,12 @@ const LIST_ALL_DEB_FILES_COMMAND: &str = r#"find . -maxdepth 1 -type f -name '*. | |
| pub fn list_all_packages(output: &str) -> GeneratorResults { | ||
| let mut targets = Vec::new(); | ||
| for package_name in output.lines() { | ||
| targets.push(Suggestion::with_description( | ||
| package_name.to_string(), | ||
| "package", | ||
| )); | ||
| if !package_name.is_empty() { | ||
| targets.push(Suggestion::with_description( | ||
| package_name.to_string(), | ||
| "package", | ||
| )); | ||
| } | ||
| } | ||
| targets.into_iter().collect_unordered_results() | ||
| } | ||
|
|
@@ -40,6 +42,9 @@ pub fn list_available_packages(output: &str) -> GeneratorResults { | |
| pub fn list_all_deb_files_in_cwd(output: &str) -> GeneratorResults { | ||
| let mut targets = Vec::new(); | ||
| for file in output.lines() { | ||
| if file.is_empty() { | ||
| continue; | ||
| } | ||
| targets.push( | ||
| // We should prioritize .deb files over the already installed packages. | ||
| Suggestion::with_description(file.to_string(), ".deb file") | ||
|
|
@@ -98,3 +103,4 @@ pub fn aptitude_generators() -> CommandSignatureGenerators { | |
| ), | ||
| ) | ||
| } | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. important — This EOF blank line is the sole cause of the failing |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
important —
str::lines()treats the final line ending as optional, so the ordinary trailing newline fromdpkg-queryyields no empty segment and cannot produce the blank suggestion #380 describes. This guard therefore only filters a genuine interior blank line or a doubled trailing newline, meaning the reported reproduction is not the one being fixed here. Confirm the input that actually reproduces and pin it with a test, or narrow #380 and this change to that case.