Skip to content

Commit

Permalink
Fix issue of output text not showing up on first run (fixes #445)
Browse files Browse the repository at this point in the history
Signed-off-by: PranavPurwar <purwarpranav80@gmail.com>
  • Loading branch information
PranavPurwar committed Sep 25, 2023
1 parent f54cadf commit 48a38ac
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
16 changes: 14 additions & 2 deletions app/src/main/kotlin/org/cosmicide/adapter/EditorAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
* You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see <https://www.gnu.org/licenses/>.
*/

/*
* This file is part of Cosmic IDE.
* Cosmic IDE is a free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* Cosmic IDE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see <https://www.gnu.org/licenses/>.
*/

package org.cosmicide.adapter

import android.content.res.Configuration
Expand All @@ -28,7 +35,6 @@ import io.github.rosemoe.sora.event.ContentChangeEvent
import io.github.rosemoe.sora.event.SubscriptionReceipt
import io.github.rosemoe.sora.lang.EmptyLanguage
import io.github.rosemoe.sora.langs.textmate.TextMateColorScheme
import io.github.rosemoe.sora.langs.textmate.TextMateLanguage
import io.github.rosemoe.sora.langs.textmate.registry.ThemeRegistry
import io.github.rosemoe.sora.widget.subscribeEvent
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -215,7 +221,13 @@ class EditorAdapter(val fragment: Fragment, val fileViewModel: FileViewModel) :
}

"class" -> {
editor.setEditorLanguage(TextMateLanguage.create("source.java", true))
editor.setEditorLanguage(
TsLanguageJava.getInstance(
editor,
project,
file
)
)
}

else -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
* You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see <https://www.gnu.org/licenses/>.
*/

/*
* This file is part of Cosmic IDE.
* Cosmic IDE is a free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* Cosmic IDE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see <https://www.gnu.org/licenses/>.
*/

package org.cosmicide.fragment

import android.os.Bundle
Expand Down Expand Up @@ -91,7 +98,8 @@ class ProjectOutputFragment : BaseBindingFragment<FragmentCompileInfoBinding>()
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE)
}
}
checkClasses()

binding.infoEditor.postDelayed(::checkClasses, 250)
}

fun checkClasses() {
Expand Down Expand Up @@ -126,7 +134,6 @@ class ProjectOutputFragment : BaseBindingFragment<FragmentCompileInfoBinding>()
text.getColumnCount(text.lineCount - 1),
p0.toChar().toString()
)
binding.infoEditor.invalidate()
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
* You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see <https://www.gnu.org/licenses/>.
*/

/*
* This file is part of Cosmic IDE.
* Cosmic IDE is a free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* Cosmic IDE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with Cosmic IDE. If not, see <https://www.gnu.org/licenses/>.
*/

/*
* This file is part of Cosmic IDE.
* Cosmic IDE is a free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Expand Down Expand Up @@ -106,7 +113,11 @@ private fun prepareCleanerCallback(): ((ByteBuffer) -> Unit)? {
return try {
// API 26+ already allow using these methods
// if (IS_PRIOR_9_JRE) {
val cleaner = Class.forName("java.nio.DirectByteBuffer").getMethod("cleaner")
val directByteBuffer = Class.forName("java.nio.DirectByteBuffer")
if (directByteBuffer.declaredMethods.any { it.name == "cleaner" }.not()) {
return null
}
val cleaner = directByteBuffer.getMethod("cleaner")
cleaner.isAccessible = true

val clean = Class.forName("sun.misc.Cleaner").getMethod("clean")
Expand Down

0 comments on commit 48a38ac

Please sign in to comment.