···1515const TITLECACHEFILE: &str = "cache";
1616/// A unique identifier for a task. When referenced in text, it is prefixed with `tsk-`.
1717#[derive(Clone, Copy, Debug, Eq, PartialEq)]
1818-pub struct Id(u32);
1818+pub struct Id(pub u32);
19192020impl FromStr for Id {
2121 type Err = Error;
···154154 let third = stack.pop();
155155156156 if top.is_none() || second.is_none() || third.is_none() {
157157- return Ok(())
157157+ return Ok(());
158158 }
159159160160 stack.push(second.unwrap());
···173173 let third = stack.pop();
174174175175 if top.is_none() || second.is_none() || third.is_none() {
176176- return Ok(())
176176+ return Ok(());
177177 }
178178179179 stack.push(top.unwrap());
···201201 pub fn search(&self) -> Result<Option<Id>> {
202202 let stack = self.read_stack()?;
203203 Ok(fzf::select(stack)?.map(|si| si.id))
204204+ }
205205+206206+ pub fn reprioritize(&self, id: Id) -> Result<()> {
207207+ let mut stack = self.read_stack()?;
208208+ let index = &stack.iter().map(|i| i.id).position(|i| i == id);
209209+ if let Some(index) = index {
210210+ let prioritized_task = stack.remove(*index);
211211+ // unwrap here is safe because we just searched for the index and know it exists
212212+ stack.push(prioritized_task.unwrap());
213213+ stack.save()?;
214214+ }
215215+ Ok(())
204216 }
205217}
206218