firepad icon indicating copy to clipboard operation
firepad copied to clipboard

Blank page after undo, after setText

Open sbrown345 opened this issue 9 years ago • 2 comments

http://plnkr.co/edit/eHfBW8vHac7033PoNQwk?p=preview

Start with a firepad with some content in. Use setText to set some arbitary text, and then undo. The first undo state is a blank page, you have to undo again to get back to the previous text.

I'd expect the first undo to be the original content, not a blank page.

It happens with codemirror, ace, and the rich text editor. I've even tried using ace editor's 'setValue' with the same result. Once I disconnected firepad from the ace editor and used setValue it worked as expected: http://plnkr.co/edit/DoZ5RsyI5crU1ZbhAqYG?p=preview

sbrown345 avatar May 04 '16 19:05 sbrown345

Good point. The fix is probably to wrap the setText implementation (the setValue and insertText calls at least) here https://github.com/firebase/firepad/blob/master/lib/firepad.js#L185 in a cm.operation() [see here https://github.com/firebase/firepad/blob/master/lib/firepad.js#L207 for example].

On Wed, May 4, 2016 at 12:10 PM, Simon Brown [email protected] wrote:

http://plnkr.co/edit/eHfBW8vHac7033PoNQwk?p=preview

Start with a firepad with some content in. Use setText to set some arbitary text, and then undo. The first undo state is a blank page, you have to undo again to get back to the previous text.

I'd expect the first undo to be the original content, not a blank page.

It happens with codemirror, ace, and the rich text editor. I've even tried using ace editor's 'setValue' with the same result. Once I disconnected firepad from the ace editor and used setValue it worked as expected: http://plnkr.co/edit/DoZ5RsyI5crU1ZbhAqYG?p=preview

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/firebase/firepad/issues/242

mikelehen avatar May 04 '16 20:05 mikelehen

I guess cm.operation() is just for CodeMirror, is there an equivalent to cm.operation() for ace?

sbrown345 avatar May 06 '16 06:05 sbrown345