News for hackers. Stuff that matters.
Re:Rust Playground by peferron on Sunday May 24, 2015 @01:19PM (#9596835)
I've been using the Rust playground a lot this week, and I wish it had a history feature - I often closed a tab and later wished I could get the code back.

I'm thinking about trying to contribute a localStorage-based history mechanism. Does anyone else think it'd be a good addition? And if so, any suggestions regarding the behavior?

Re:Rust Playground by MJSplot_author on Sunday May 24, 2015 @03:00PM (#9597165)
I think I would be good. They are using the ace text editor, so something simple like:

on pageload: var t = localStorage.getItem("textbackup"); if (t){ __editor.setValue(t); console.log('restoring from backup'); } else { __editor.setValue(document.getElementById('basic_intro').innerHTML); console.log('putting in the intro'); }

and on any action: var text = __editor.getValue(); localStorage.setItem('textbackup', text);

It's the approach I've taken in my version a playground for a different program. http://xqt2.com/mjslab/mjslab.html

Re:Rust Playground by peferron on Sunday May 24, 2015 @03:19PM (#9597238)
That's definitely useful, but the current Rust playground already does this (sorry for not being clear in my post). I meant a more full-featured history where you can view multiple previous edits, not just restore the last one.
Re:Rust Playground by mbrubeck on Sunday May 24, 2015 @03:01PM (#9597173)
It would be great if this could also show diffs to previous versions!