firepad icon indicating copy to clipboard operation
firepad copied to clipboard

Concurrent editing produces extra user selection highlight

Open marinabilles opened this issue 8 years ago • 0 comments

Firebase: 3.3.0

Firepad: 1.4.0

CodeMirror: 5.18.2

Other: Firefox ESR 45.5.0, Ubuntu 16.04

Test case

Just the default Firepad CodeMirror setup

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Firepad</title>

    <!-- Firebase -->
    <script src="https://www.gstatic.com/firebasejs/3.3.0/firebase.js"></script>

    <!-- CodeMirror -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.18.2/codemirror.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.18.2/codemirror.css"/>

    <!-- Firepad -->
    <link rel="stylesheet" href="https://cdn.firebase.com/libs/firepad/1.4.0/firepad.css" />
    <script src="https://cdn.firebase.com/libs/firepad/1.4.0/firepad.js"></script>
</head>
<body>
    <div id="firepad"></div>
    <script>
        window.addEventListener("load", function() {
            // Initialize the Firebase SDK.
            firebase.initializeApp({
                apiKey: "...",
                databaseURL: "... .firebaseio.com"
            });

            initialize();
        });

        var initialized = false;
        function initialize() {
            if (initialized) return;
            initialized = true;
            // Get Firebase Database reference.
            var firepadRef = firebase.database().ref();

            // Create CodeMirror (with lineWrapping on).
            var codeMirror = CodeMirror(document.getElementById('firepad'), { lineWrapping: true });

            // Create Firepad (with rich text toolbar and shortcuts enabled).
            Firepad.fromCodeMirror(firepadRef, codeMirror,
                    { richTextShortcuts: true, richTextToolbar: true, defaultText: 'Hello, World!' });
        }
    </script>
</body>
</html>

Steps to reproduce

A concurrent editing synchronization problem appears when modifying the contents of the CodeMirror editor with two clients at the same time. This happens intermittently and is very hard to reproduce manually, though I have done so with a colleague.

Assume that we have an existing text "a" that is bold. Now, user 1 writes another "a" into the editor. Meanwhile, user 2 selects the text, clicks on the bold button and then quickly focuses the text again (e.g. by pressing the right arrow key).

Expected behavior

Normally, user 1 sees a highlight for those characters that are currently selected by user 2.

Actual behavior

After synchronizing the conflicting changes above, user 2's highlight (in light green) is not cleared on user 1's screen.

firepad_bug_report_img

marinabilles avatar Jan 19 '17 13:01 marinabilles