Skip to content

editor.experimentalEditContextEnabled breaks text input in aux editors #229825

Closed

Description

Type: Bug

If I enable editor.experimentalEditContextEnabled then I'm unable to type (add new text) in aux editors. Removing text works

Steps to reproduce:

  1. Set "editor.experimentalEditContextEnabled": true
  2. Open text editor in main window and try to type - text should be entered as usual
  3. Drag editor to create aux window
  4. Try to type text in aux editor - nothing added (while all letters are registered in screencast mode)
    • Backspace, Del, Ctrl+/ and other shortcuts work as expected
aux_edit_broken.mp4

VS Code version: Code - Insiders 1.94.0-insider (c43f508, 2024-09-26T05:04:07.935Z)
OS version: Windows_NT x64 10.0.22631
Modes:

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz (8 x 2996)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 31.50GB (13.12GB free)
Process Argv
Screen Reader no
VM 0%
Extensions disabled

Activity

  1. changed the title [-]editor.experimentalEditContextEnabled breaks text input in aux editors[/-] [+]`editor.experimentalEditContextEnabled` breaks text input in aux editors[/+] on Sep 26, 2024
  2. IllusionMH commented on Sep 26, 2024

    @IllusionMH
    ContributorAuthor

    /assign aiday-mar -jrieken

  3. aiday-mar commented on Sep 26, 2024

    @aiday-mar
    Collaborator

    Hi yes thank you for filing this valuable issue. I am able to reproduce this both on insiders.vscode.dev as well as on desktop. This is a strange issue, the edit context no longer receives text update events in auxilliary windows. I believe this could be a chromium/electron bug, will investigate.

  4. added
    bug
    on Sep 26, 2024
  5. aiday-mar commented on Sep 27, 2024

    @aiday-mar
    Collaborator

    Thanks a lot for opening this issue. I have created a small HTML/JS example which indicates this is likely a chromium bug. To reproduce on this smaller example do the following:

    1. Take the following HTML page:
    <!DOCTYPE html>
    <html>
    
    <head>
    </head>
    
    <body>
        <p>
            Edit Context With Aux window<br>
    
            1. Open the dev tools right now<br>
            2. Type some text in the editor below, no text should appear which is normal because we don't modify the div
            with
            the EditContext. Be quick before the aux window appears in 10 seconds (you can increase the timeout in the HTML
            page). <br>
            3. Notice how the text-update AND the keydown listener send events that are logged in the console<br>
            4. Wait for 10 seconds for the auxiliary window to appear into which the body of the current window is
            appended<br>
            5. Open the dev tools on that window<br>
            6. Place the windows side-by-side<br>
            7. Type into the editor of the aux window<br>
            8. Notice that this div is editable whereas before it was not? [bug]<br>
            9. Notice that on typing, only the keydown listener in the first window fires, the text-update event does not
            fire[bug]<br>
        </p>
    
        <div id="html-editor" spellcheck="false" style="border:1px solid black"></div>
    
        <script>
            const IS_EDIT_CONTEXT_SUPPORTED = 'EditContext' in window;
            console.log('IS_EDIT_CONTEXT_SUPPORTED : ', IS_EDIT_CONTEXT_SUPPORTED);
    
            const editorEl = document.getElementById("html-editor");
            editorEl.style.height = '200px';
            editorEl.style.width = '100%';
    
            if (IS_EDIT_CONTEXT_SUPPORTED) {
                const editContext = new EditContext();
                editorEl.editContext = editContext;
    
                editContext.addEventListener("textupdate", e => {
                    console.log('textupdate : ', e);
                });
                editorEl.addEventListener('keydown', e => {
                    console.log('keydown : ', e);
                });
    
                setTimeout(() => {
                    const body = window.document.body;
                    const newWindow = window.open();
                    newWindow?.window?.document.body.append(body);
                    console.log('body : ', body);
                    console.log('newWindow : ', newWindow);
                }, 10000)
            }
        </script>
    </body>
    
    </html>
    
    1. Open in Chrome
    2. Open the dev tools as soon as the page appears
    3. Type some text in the editor, no text should appear which is normal because we don't modify the div with the EditContext. Be quick before the aux window appears in 10 seconds (you can increase the timeout in the HTML page)
    4. Notice how the text-update AND the keydown listener send events that are logged in the console
    5. Wait for 10 seconds for the auxiliary window to appear into which the body of the current window is appended
    6. Open the dev tools on that aux window
    7. Place the main and the aux window side-by-side
    8. Type into the editor of the aux window
    9. Notice that this div is editable whereas before it was not before 🐛
    10. Notice that on typing, only the keydown listener in the first window fires, the text-update event does not fire 🐛
    Screen.Recording.2024-09-27.at.17.10.51.mov

    I will create an issue with the chromium team and link it here.

    cc Robo (@deepak1556) Benjamin Pasero (@bpasero)

  6. aiday-mar commented on Sep 27, 2024

    @aiday-mar
    Collaborator
  7. added
    upstream-issue-linked
    on Sep 27, 2024
  8. aiday-mar commented on Oct 2, 2024

    @aiday-mar
    Collaborator

    After some discussion with the team, we will work on a workaround, which consists in instantiating the edit context in the newly created window. For that the window ID will have to be passed down into the editor/view constructor.

  9. aiday-mar commented on Oct 9, 2024

    @aiday-mar
    Collaborator

    This issue will be closed as a workaround fix has been added.

  10. IllusionMH commented on Oct 9, 2024

    @IllusionMH
    ContributorAuthor

    Looks like "editor.experimentalEditContextEnabled": true, works for me in aux windows now. Unable to repro my previous problems.

    Thanks!

  11. locked and limited conversation to collaborators on Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugeditor-edit-contextupstream-issue-linked

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions