Replies: 18 comments 1 reply
-
I'm not sure I understand the intent here. Any changes done to the model will result in change events being emitted (e.g. to update the view or the language services that provide rich language features). What would be the use case for changing a model and inhibiting events? |
Beta Was this translation helpful? Give feedback.
-
The distinction lies in the event source. Are events triggered by the user or code? In my case I want to listen to user triggered events, but also set the editor content and cursor position using code. The current solution is to unbind and rebind listeners each time. Is this clearer? |
Beta Was this translation helpful? Give feedback.
-
This is a common problem I also hit often. Usually I use a code pattern like the following: var ignoreEventBecauseIAmTriggeringIt = false;
emitter.onBla(function(e) {
if (ignoreEventBecauseIAmTriggeringIt) {
return;
}
console.log('Now I should react to ', e, ' because someone else caused it');
});
...
// Do something that makes `onBla` fire:
try {
ignoreEventBecauseIAmTriggeringIt = true;
emitter.changeBla(..);
} finally {
ignoreEventBecauseIAmTriggeringIt = false;
} |
Beta Was this translation helpful? Give feedback.
-
Thats essentially what I'm doing @alexandrudima. To avoid race conditions I think it would be great to have a way to know what caused the event, e.g. the user or the code. This would also be valuable for widgets and other feedback. |
Beta Was this translation helpful? Give feedback.
-
+1. For eg. In Codemirror for every change you also get it's origin - if it was a user input or setValue call. |
Beta Was this translation helpful? Give feedback.
-
agreed it would be useful to have this distinction - would make it play with angular's ControlValueAccessor API much better: angular/angular#20230 (comment) |
Beta Was this translation helpful? Give feedback.
-
It would be great if the 'source' parameter of the 'executeEdits' function could be obtained in the 'onDidChangeModelContent' function. |
Beta Was this translation helpful? Give feedback.
-
after toggling to a different file , im unable to get previous changes using ctrl + z for previous file.. any help would be appreciable |
Beta Was this translation helpful? Give feedback.
-
This is still an issue and a fairly important one. Any update on this? |
Beta Was this translation helpful? Give feedback.
-
This has cropped up for me as well. Trying to build an instance so an instance of the editor and model can be edited from a web socket event, but I don't want it to trigger the event |
Beta Was this translation helpful? Give feedback.
-
I'll just add here that it's fairly standard practice to be have this functionality.... Ace editor, Code mirror, even back as far as Jquery widgets have this. |
Beta Was this translation helpful? Give feedback.
-
I had the same problem and found a solution/workaround : isFlush property from onDidChangeModelContent event. Try this : editor.onDidChangeModelContent(e => {
if (e.isFlush) {
// true if setValue call
} else {
// false if user input
}
}); |
Beta Was this translation helpful? Give feedback.
-
Any update on this issue? |
Beta Was this translation helpful? Give feedback.
-
Hi, I have same problem. |
Beta Was this translation helpful? Give feedback.
-
Hi, I have same problem. |
Beta Was this translation helpful? Give feedback.
-
I need this to prevent event if the change is made by formatter. |
Beta Was this translation helpful? Give feedback.
-
@DanielJefferson1990
|
Beta Was this translation helpful? Give feedback.
-
Any updates on this? |
Beta Was this translation helpful? Give feedback.
-
We only want to listen to user-triggered events. It looks like
_resetValue
would allow for this (I get it, it's supposed to be private). However, we can't seem to use it because the necessary functiontoRawText
defined onTextModel
seems to be unaccessible.How can we change the editor text value without triggering a change event?
Beta Was this translation helpful? Give feedback.
All reactions