diff --git a/services/web/frontend/js/features/ide-react/editor/document-container.ts b/services/web/frontend/js/features/ide-react/editor/document-container.ts index bbb08bd093..9172ec9ff8 100644 --- a/services/web/frontend/js/features/ide-react/editor/document-container.ts +++ b/services/web/frontend/js/features/ide-react/editor/document-container.ts @@ -18,6 +18,7 @@ import { import { isCommentOperation, isDeleteOperation, + isEditOperation, isInsertOperation, } from '@/utils/operations' import { decodeUtf8 } from '@/utils/decode-utf8' @@ -584,10 +585,14 @@ export class DocumentContainer extends EventEmitter { window.clearTimeout(docChangedTimeout) } docChangedTimeout = window.setTimeout(() => { - window.dispatchEvent( - new CustomEvent('doc:changed', { detail: { id: this.doc_id } }) - ) - this.ideEventEmitter.emit('doc:changed', { doc_id: this.doc_id }) + if (ops.some(isEditOperation)) { + window.dispatchEvent( + new CustomEvent('doc:changed', { detail: { id: this.doc_id } }) + ) + this.ideEventEmitter.emit('doc:changed', { + doc_id: this.doc_id, + }) + } }, 50) } ) diff --git a/services/web/frontend/js/utils/operations.ts b/services/web/frontend/js/utils/operations.ts index 8fcb2242b3..936eb8a508 100644 --- a/services/web/frontend/js/utils/operations.ts +++ b/services/web/frontend/js/utils/operations.ts @@ -15,6 +15,9 @@ export const isCommentOperation = (op: Operation): op is CommentOperation => export const isDeleteOperation = (op: Operation): op is DeleteOperation => 'd' in op +export const isEditOperation = (op: Operation): op is EditOperation => + isInsertOperation(op) || isDeleteOperation(op) + export const isInsertChange = ( change: Change ): change is Change => isInsertOperation(change.op)