rust-playground icon indicating copy to clipboard operation
rust-playground copied to clipboard

Add the ability to reset the editor buffer back to the original "hello world" state.

Open vext01 opened this issue 6 years ago • 9 comments

Hi,

The rust playground remembers the last buffer you were working on. That's very useful, but sometimes I want to start afresh. I can't see a way to do this currently. Could there be a "clear" button which resets the buffer back to the default "hello world"?

Thanks

vext01 avatar May 08 '18 09:05 vext01

I think this is something that can be done. A super hacky way of doing this now would be to clear your browser state for the playground, but that clears everything.

shepmaster avatar May 09 '18 19:05 shepmaster

If someone starts working on this, a semi-related request I've heard would be to have some "templates" of interesting pieces of code (e.g. a WASM hello world, or maybe a Futures example) to showcase pieces of the ecosystem. That's a bigger step, but might be worth keeping in the back of your mind.

shepmaster avatar May 09 '18 19:05 shepmaster

to have some "templates" of interesting pieces of code

sounds good to me.

You could even go as far as a vim-tutor style experience for learning Rust interactively.

But perhaps you should raise a new issue for that.

Thanks

vext01 avatar May 10 '18 09:05 vext01

An extremely non-obvious thing you can do is to erase all the text and reload the page. This will reload the "hello world" example.

shepmaster avatar Sep 17 '18 14:09 shepmaster

I just tested the suggestion above, and it doesn't seem to work any more -- reloading the page just reloads the empty text now. Having an explicit "reset" button would be great!

hdevalence avatar Aug 13 '19 17:08 hdevalence

One potential enhancement: start tracking the last time someone visited. If they haven't visited in "long enough", then proactively offer to reset back to defaults.

shepmaster avatar May 06 '20 01:05 shepmaster

I'm posting the default "Hello World" code here to make it easier for posterity to copy and paste it:

fn main() {
    println!("Hello, world!");
}

PaulRBerg avatar Nov 24 '20 21:11 PaulRBerg

I attempted to use the Playground via Chrome app on iOS. I basically failed for this reason - my browser had a large example and there’s no way to select all text for mass delete. Deleting character by character is very slow (and reverts to half speed if holding delete down, for unknown reasons). In the end I couldn’t find a way to reset the playground and had to give up.

Incidentally the “hold space to move cursor” technique doesn’t work either - something about the editor window is unfriendly to iOS.

DavidAntliff avatar Apr 08 '23 02:04 DavidAntliff

For mobile users, I encourage using the simple editor:

image

Neither Ace nor Monaco work well in most mobile environments. The simple editor is just a browser-native text area.

shepmaster avatar Apr 11 '23 00:04 shepmaster