From 023bbab9e404dcadb8f2c68d0d239d2106eb1d19 Mon Sep 17 00:00:00 2001 From: Akash Yadav Date: Tue, 3 Oct 2023 17:59:25 +0530 Subject: [PATCH] fix(editor): modified status is not updated after save (fixes #1359) --- .../java/com/itsaky/androidide/editor/ui/IDEEditor.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/editor/src/main/java/com/itsaky/androidide/editor/ui/IDEEditor.kt b/editor/src/main/java/com/itsaky/androidide/editor/ui/IDEEditor.kt index 0228e1521..50ef8fff9 100644 --- a/editor/src/main/java/com/itsaky/androidide/editor/ui/IDEEditor.kt +++ b/editor/src/main/java/com/itsaky/androidide/editor/ui/IDEEditor.kt @@ -86,6 +86,7 @@ import io.github.rosemoe.sora.widget.IDEEditorSearcher import io.github.rosemoe.sora.widget.component.EditorAutoCompletion import io.github.rosemoe.sora.widget.component.EditorBuiltinComponent import io.github.rosemoe.sora.widget.component.EditorTextActionWindow +import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -441,12 +442,8 @@ open class IDEEditor @JvmOverloads constructor( EventBus.getDefault().unregister(this) } - try { - if (editorScope.isActive) { - editorScope.cancelIfActive("Editor is releasing resources.") - } - } catch (e: Exception) { - log.error("Failed to close coroutine dispatcher", e) + if (editorScope.isActive) { + editorScope.cancelIfActive("Editor is releasing resources.") } } @@ -544,6 +541,7 @@ open class IDEEditor @JvmOverloads constructor( * Dispatches the [DocumentSaveEvent] for this editor. */ open fun dispatchDocumentSaveEvent() { + markUnmodified() if (getFile() == null) { return } @@ -832,7 +830,6 @@ open class IDEEditor @JvmOverloads constructor( } protected open fun dispatchDocumentSelectedEvent() { - markUnmodified() val file = file ?: return val selectedEvent = DocumentSelectedEvent(file.toPath()) EventBus.getDefault().post(selectedEvent)