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

add update method to json and text apis #244

Closed
dgreisen opened this issue Aug 25, 2013 · 2 comments
Closed

add update method to json and text apis #244

dgreisen opened this issue Aug 25, 2013 · 2 comments

Comments

@dgreisen
Copy link
Contributor

There is currently a method called applyChange in textarea.js. This function takes the existing text and updated text, and figures out and applies the insert and/or remove operations needed to transform the existing text into the updated text. This is useful in more than just the textarea case. I would like to see this method included in both the text and json apis as something like update(old, new).

@dgreisen
Copy link
Contributor Author

dgreisen commented Sep 4, 2013

@josephg: if this looks ok, I've time to work on it tomorrow. Please let me know.

@josephg
Copy link
Owner

josephg commented Sep 4, 2013

Its a hack, and I don't want to rely on it in general. The creep will look like "lets add this to JSON for strings" then "Oh, if it works for strings, we should use a diff algorithm for arrays too" "oh why not do full tree-based diff" -> "Hey, all this diffing stuff doesn't preserve intent! ShareJS doesn't work right!" or "ShareJS is so slow!"

So no, I want to inspire the sense of guilt when that dodgy diffing function is invoked. Its not necessarily a bad hack (it works great for isolated changes in small strings), but I don't want to encourage general purpose use.

@josephg josephg closed this as completed Sep 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants