-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Fixed international composition issues (e.g., Japanese Input method) #999
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) | |
| var caughtErrorCatchers = []; | ||
| var caughtErrorTimes = []; | ||
| var debugMessages = []; | ||
| var msgQueue = []; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All this msgqueue stuff make me really worry. Why is this necessary?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think its used to avoid that changesets from the server are being applyed while the editor is in "internalCompositionState"
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's correct. @fourplusone Thank you! |
||
|
|
||
| tellAceAboutHistoricalAuthors(serverVars.historicalAuthorData); | ||
| tellAceActiveAuthorInfo(initialUserInfo); | ||
|
|
@@ -110,6 +111,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) | |
|
|
||
| function handleUserChanges() | ||
| { | ||
| if (window.parent.parent.inInternationalComposition) return; | ||
| if ((!getSocket()) || channelState == "CONNECTING") | ||
| { | ||
| if (channelState == "CONNECTING" && (((+new Date()) - initialStartConnectTime) > 20000)) | ||
|
|
@@ -128,12 +130,12 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) | |
|
|
||
| if (state != "IDLE") | ||
| { | ||
| if (state == "COMMITTING" && (t - lastCommitTime) > 20000) | ||
| if (state == "COMMITTING" && msgQueue.length == 0 && (t - lastCommitTime) > 20000) | ||
| { | ||
| // a commit is taking too long | ||
| setChannelState("DISCONNECTED", "slowcommit"); | ||
| } | ||
| else if (state == "COMMITTING" && (t - lastCommitTime) > 5000) | ||
| else if (state == "COMMITTING" && msgQueue.length == 0 && (t - lastCommitTime) > 5000) | ||
| { | ||
| callbacks.onConnectionTrouble("SLOW"); | ||
| } | ||
|
|
@@ -152,6 +154,36 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) | |
| return; | ||
| } | ||
|
|
||
| // apply msgQueue changeset. | ||
| if (msgQueue.length != 0) { | ||
| while (msg = msgQueue.shift()) { | ||
| var newRev = msg.newRev; | ||
| rev=newRev; | ||
| if (msg.type == "ACCEPT_COMMIT") | ||
| { | ||
| editor.applyPreparedChangesetToBase(); | ||
| setStateIdle(); | ||
| callCatchingErrors("onInternalAction", function() | ||
| { | ||
| callbacks.onInternalAction("commitAcceptedByServer"); | ||
| }); | ||
| callCatchingErrors("onConnectionTrouble", function() | ||
| { | ||
| callbacks.onConnectionTrouble("OK"); | ||
| }); | ||
| handleUserChanges(); | ||
| } | ||
| else if (msg.type == "NEW_CHANGES") | ||
| { | ||
| var changeset = msg.changeset; | ||
| var author = (msg.author || ''); | ||
| var apool = msg.apool; | ||
|
|
||
| editor.applyChangesToBase(changeset, author, apool); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| var sentMessage = false; | ||
| var userChangesData = editor.prepareUserChangeset(); | ||
| if (userChangesData.changeset) | ||
|
|
@@ -254,6 +286,22 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) | |
| var changeset = msg.changeset; | ||
| var author = (msg.author || ''); | ||
| var apool = msg.apool; | ||
|
|
||
| // When inInternationalComposition, msg pushed msgQueue. | ||
| if (msgQueue.length > 0 || window.parent.parent.inInternationalComposition) { | ||
| if (msgQueue.length > 0) oldRev = msgQueue[msgQueue.length - 1].newRev; | ||
| else oldRev = rev; | ||
|
|
||
| if (newRev != (oldRev + 1)) | ||
| { | ||
| dmesg("bad message revision on NEW_CHANGES: " + newRev + " not " + (oldRev + 1)); | ||
| setChannelState("DISCONNECTED", "badmessage_newchanges"); | ||
| return; | ||
| } | ||
| msgQueue.push(msg); | ||
| return; | ||
| } | ||
|
|
||
| if (newRev != (rev + 1)) | ||
| { | ||
| dmesg("bad message revision on NEW_CHANGES: " + newRev + " not " + (rev + 1)); | ||
|
|
@@ -266,6 +314,18 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) | |
| else if (msg.type == "ACCEPT_COMMIT") | ||
| { | ||
| var newRev = msg.newRev; | ||
| if (msgQueue.length > 0) | ||
| { | ||
| if (newRev != (msgQueue[msgQueue.length - 1].newRev + 1)) | ||
| { | ||
| dmesg("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (msgQueue[msgQueue.length - 1][0] + 1)); | ||
| setChannelState("DISCONNECTED", "badmessage_acceptcommit"); | ||
| return; | ||
| } | ||
| msgQueue.push(msg); | ||
| return; | ||
| } | ||
|
|
||
| if (newRev != (rev + 1)) | ||
| { | ||
| dmesg("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (rev + 1)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,22 @@ var randomString = require('./pad_utils').randomString; | |
|
|
||
| var hooks = require('./pluginfw/hooks'); | ||
|
|
||
| window.inInternationalComposition = false; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why does this have to be a global?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no special reason. We're trying to fix.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| var inInternationalComposition = window.inInternationalComposition; | ||
|
|
||
| window.handleCompositionEvent = function handleCompositionEvent(evt) | ||
| { | ||
| // international input events, fired in FF3, at least; allow e.g. Japanese input | ||
| if (evt.type == "compositionstart") | ||
| { | ||
| this.inInternationalComposition = true; | ||
| } | ||
| else if (evt.type == "compositionend") | ||
| { | ||
| this.inInternationalComposition = false; | ||
| } | ||
| } | ||
|
|
||
| function createCookie(name, value, days, path) | ||
| { | ||
| if (days) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do feature detection instead of hard version checking if possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're try to fix. but to separate from #1032.