Skip to content

Instantly share code, notes, and snippets.

@calmofthestorm
Created April 10, 2020 02:55
Show Gist options
  • Save calmofthestorm/08d0afeef571312d778958a5a5c2ad69 to your computer and use it in GitHub Desktop.
Save calmofthestorm/08d0afeef571312d778958a5a5c2ad69 to your computer and use it in GitHub Desktop.
Orgize properties drawer bugs
use std::io::{Read, Write};
fn good1() {
let data = r"* Day
:PROPERTIES:
:SPAGHETTI:
:END:
";
let mut current = data.to_string();
println!("Beginning with:\n{}", &current);
for _ in 0..10 {
let org = orgize::Org::parse(&current);
let mut v = Vec::new();
let mut c = std::io::Cursor::new(&mut v);
org.write_org(&mut c).unwrap();
current = std::str::from_utf8(&v).unwrap().to_string();
}
println!(
"After 10 iterations of load/save, the file is:\n{}\n\n",
&current
);
}
fn bad1() {
let data = r"* Day
SCHEDULED: <2020-04-07 Tue .+1d>
:PROPERTIES:
:SPAGHETTI:
:END:
";
let mut current = data.to_string();
println!("Beginning with:\n{}", &current);
for _ in 0..10 {
let org = orgize::Org::parse(&current);
let mut v = Vec::new();
let mut c = std::io::Cursor::new(&mut v);
org.write_org(&mut c).unwrap();
current = std::str::from_utf8(&v).unwrap().to_string();
}
println!(
"After 10 iterations of load/save, the file is:\n{}\n\n",
&current
);
}
fn bad2() {
let data = r"* TODO Day
SCHEDULED: <2020-04-07 Tue .+1d>
:PROPERTIES:
:LAST_REPEAT: [2020-04-06 Mon 10:45]
:END:
:END:
";
let mut current = data.to_string();
println!("Beginning with:\n{}", &current);
for _ in 0..10 {
let org = orgize::Org::parse(&current);
let mut v = Vec::new();
let mut c = std::io::Cursor::new(&mut v);
org.write_org(&mut c).unwrap();
current = std::str::from_utf8(&v).unwrap().to_string();
}
println!(
"After 10 iterations of load/save, the file is:\n{}\n\n",
&current
);
}
fn bad3() {
let data = r"* TODO Day
SCHEDULED: <2020-04-07 Tue .+1d>
:PROPERTIES:
:LAST_REPEAT: [2020-04-06 Mon 10:45]
:END:
:END:
hello how are you?
:DRAWER:
:END:
hi
:END:
";
let mut current = data.to_string();
println!("Beginning with:\n{}", &current);
for _ in 0..10 {
let org = orgize::Org::parse(&current);
let mut v = Vec::new();
let mut c = std::io::Cursor::new(&mut v);
org.write_org(&mut c).unwrap();
current = std::str::from_utf8(&v).unwrap().to_string();
}
println!(
"After 10 iterations of load/save, the file is:\n{}\n\n",
&current
);
}
fn bad4() {
let data = r"* TODO Day
SCHEDULED: <2020-04-07 Tue .+1d>
:PROPERTIES:
:LAST_REPEAT: [2020-04-06 Mon 10:45]
:NOTDRAWER:
";
let mut current = data.to_string();
println!("Beginning with:\n{}", &current);
for _ in 0..10 {
let org = orgize::Org::parse(&current);
let mut v = Vec::new();
let mut c = std::io::Cursor::new(&mut v);
org.write_org(&mut c).unwrap();
current = std::str::from_utf8(&v).unwrap().to_string();
}
println!(
"After 10 iterations of load/save, the file is:\n{}\n\n",
&current
);
}
fn main() {
good1();
println!("\n\n------------------------\n\n");
bad1();
println!("\n\n------------------------\n\n");
bad2();
println!("\n\n------------------------\n\n");
bad3();
println!("\n\n------------------------\n\n");
bad4();
}
Beginning with:
* Day
:PROPERTIES:
:SPAGHETTI:
:END:
After 10 iterations of load/save, the file is:
* Day
:PROPERTIES:
:SPAGHETTI:
:END:
------------------------
Beginning with:
* Day
SCHEDULED: <2020-04-07 Tue .+1d>
:PROPERTIES:
:SPAGHETTI:
:END:
After 10 iterations of load/save, the file is:
* Day
SCHEDULED: <2020-04-07 Tue .+1d>
:PROPERTIES:
:SPAGHETTI:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
------------------------
Beginning with:
* TODO Day
SCHEDULED: <2020-04-07 Tue .+1d>
:PROPERTIES:
:LAST_REPEAT: [2020-04-06 Mon 10:45]
:END:
:END:
After 10 iterations of load/save, the file is:
* TODO Day
SCHEDULED: <2020-04-07 Tue .+1d>
:PROPERTIES:
:LAST_REPEAT: [2020-04-06 Mon 10:45]
:END:
:END:
:END:
------------------------
Beginning with:
* TODO Day
SCHEDULED: <2020-04-07 Tue .+1d>
:PROPERTIES:
:LAST_REPEAT: [2020-04-06 Mon 10:45]
:END:
:END:
hello how are you?
:DRAWER:
:END:
hi
:END:
After 10 iterations of load/save, the file is:
* TODO Day
SCHEDULED: <2020-04-07 Tue .+1d>
:PROPERTIES:
:LAST_REPEAT: [2020-04-06 Mon 10:45]
:END:
:END:
hello how are you?
:DRAWER:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
hi
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
------------------------
Beginning with:
* TODO Day
SCHEDULED: <2020-04-07 Tue .+1d>
:PROPERTIES:
:LAST_REPEAT: [2020-04-06 Mon 10:45]
:NOTDRAWER:
After 10 iterations of load/save, the file is:
* TODO Day
SCHEDULED: <2020-04-07 Tue .+1d>
:PROPERTIES:
:LAST_REPEAT: [2020-04-06 Mon 10:45]
:NOTDRAWER:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
:END:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment