ashmind / mirrorsharp

MirrorSharp is a code editor <textarea> built on Roslyn and CodeMirror
BSD 2-Clause "Simplified" License
220 stars 39 forks source link

Is this a caching problem? #186

Closed Sicos1977 closed 1 year ago

Sicos1977 commented 2 years ago

When I type something in MirrorSharp and use CTRL + Z to undo that and fix it MirrorSharp still's keep complaining about the error I made but it is already fixed. Is this somekind of caching problem and is there a way to solve this?

image

In the example above it is complaining about 'e' but I already fixed that.

ashmind commented 2 years ago

Thanks for reporting. Hmm, I would expect it is a bug in how undo is sent to the server -- I'll have to investigate.

Sicos1977 commented 2 years ago

I don't know if it makes any difference but I'm using MirrorSharp on the .net 4.8 framework with ASP.NET webforms (yes I know this is old technology :-) )

Sicos1977 commented 2 years ago

Also get it when I type to fast :-)

image

When I remove this line public string KetenProcess { get; set; } and paste it back then the error goes away

Sicos1977 commented 2 years ago

I also can break everything by just selecting a large portion of code, delete it, paste it back, delete it again and past it back again. For some reason then all code editing features are broken.

The weird thing is that I don't see any errors anywhere, not in the Chrome console or on the server. It just stops working.

I also turned on self debug but that also stops working, when I press CTRL + SHIFT + Y nothing gets send back to the console.

The only way to get it working again is by reloading the webpage.

Sicos1977 commented 2 years ago

I did some more test and inspected the object in Chrome and in this example I see something different in the "code behind" then what I see on the screen. This also explains why Roslyn is complaining the code is not correct.

In this a problem I have to look into in codemirror itself or is this a problem combination between codemirror and mirrorsharp?

image

Sicos1977 commented 2 years ago

image

Sicos1977 commented 2 years ago

Any change that this gets fixed because it is sometimes very annoying that mirrorsharp is complaining that something is wrong in the code when it isn't

And could you otherwise point me in the right direction so that I can look if I can solve it myself?

Sicos1977 commented 2 years ago

Most of the time the problem occurs after just typing .. e.g. the var keyword --> mirrorsharp is suggestion sometime wrong --> I undo it and then this happens.

image

image

Sicos1977 commented 2 years ago

Uncaught Error: Unexpected undefined value at completion info index. at ensureDefined (ensure-defined.js:4:15) at Connection.sendCompletionState (connection.js:173:19) at hinter.js:94:48

Sicos1977 commented 2 years ago

Can you (or somebody else) please give an answer so that I'm not talking to a black hole?

I logged the messages to the console that I get back from mirrorsharp and that still thinks there is something different on the screen then there is really there.

This is what I see image

This is what I see in the html elements image

And this is what the slowupdate process is thinking image

Sicos1977 commented 2 years ago

I think I got it solved by removing this code from the editor.js file and the method this[editorOnCodeMirrorChanges] = (_, changes) => {

When typing to quick or moving to quick around in CodeMirror the server gets lots in where you are editing. After removing this code I don't have any problems anymore with weird suggestions

                if (cursorIndex === start + 1 && text.length === 1 && !this[editorChangesAreFromServer]) {
                    if (length > 0) {
                        // eslint-disable-next-line @typescript-eslint/no-floating-promises
                        this[editorConnection].sendReplaceText(start, length, "", cursorIndex - 1);
                    } // eslint-disable-next-line @typescript-eslint/no-floating-promises

                    this[editorConnection].sendTypeChar(text);

                } else {
Sicos1977 commented 2 years ago

Only now the tooltip window seems to be broken.

Sicos1977 commented 2 years ago

Any updates on this?

Sicos1977 commented 1 year ago

This is solved