Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undo the first time,but the history.stack.redo.length = 0? #1376

Closed
perezpz opened this issue Mar 24, 2017 · 3 comments
Closed

undo the first time,but the history.stack.redo.length = 0? #1376

perezpz opened this issue Mar 24, 2017 · 3 comments

Comments

@perezpz
Copy link

perezpz commented Mar 24, 2017

monitor 'Quill.events.EDITOR_CHANGE', and undo the first time, but the history.stack.redo.length = 0?

Expected behavior:
undo the first time I expect the history.stack.redo.length !=0 , and i can do something...

Actual behavior:
quill.history.stack.redo.length = 0

Platforms:
chrome

Version
1.2.2

@sferoze
Copy link
Contributor

sferoze commented Mar 25, 2017

@OnlyBreak I am using the quill history module and I do not see this issue. It works as expected...

@quill-bot
Copy link

Closing inactive issue.

@nikparo
Copy link
Contributor

nikparo commented Jan 10, 2018

This is the relevant code from history.js:

change(source, dest) {
  if (this.stack[source].length === 0) return;
  let delta = this.stack[source].pop();
  this.lastRecorded = 0;
  this.ignoreChange = true;
  this.quill.updateContents(delta[source], Quill.sources.USER);
  this.ignoreChange = false;
  let index = getLastChangeIndex(delta[source]);
  this.quill.setSelection(index);
  this.stack[dest].push(delta);
}

The destination stack length (redo when undoing, and vice versa) is updated after updateContents and setSelection. As such the history stack is not quite correct during any editor-change events.

Should maybe this.stack[dest].push(delta); be moved up a few lines?

nikparo added a commit to nikparo/quill that referenced this issue Jan 10, 2018
jhchen pushed a commit that referenced this issue Jan 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants