Fixed last desktop action from desktop file losing the last key value pair

This commit is contained in:
Kirottu
2023-04-09 20:50:18 +03:00
parent 7a7fb55e74
commit 1bc8d4d3d1

View File

@@ -30,11 +30,15 @@ impl DesktopEntry {
let mut line = None; let mut line = None;
let mut new_sections = Vec::new(); let mut new_sections = Vec::new();
for section in sections.iter() { for (i, section) in sections.iter().enumerate() {
if let Some(line) = line { if let Some(line) = line {
let mut section = section.to_vec(); let mut section = section.to_vec();
section.insert(0, line); section.insert(0, line);
section.pop();
// Only pop the last redundant entry if it isn't the last item
if i < sections.len() - 1 {
section.pop();
}
new_sections.push(section); new_sections.push(section);
} }
line = Some(section.last().unwrap_or(&"")); line = Some(section.last().unwrap_or(&""));