🚧 error handling and show tutorial button
This commit is contained in:
parent
d4b6d2d819
commit
a49197068f
4 changed files with 33 additions and 19 deletions
|
|
@ -78,6 +78,28 @@ class WelcomeDialogWrapper(val project: Project) : DialogWrapper(true) {
|
|||
}
|
||||
}
|
||||
|
||||
fun showTutorial(project: Project) {
|
||||
ContinuePluginStartupActivity::class.java.getClassLoader().getResourceAsStream("continue_tutorial.py").use { `is` ->
|
||||
if (`is` == null) {
|
||||
throw IOException("Resource not found: continue_tutorial.py")
|
||||
}
|
||||
var content = StreamUtil.readText(`is`, StandardCharsets.UTF_8)
|
||||
if (!System.getProperty("os.name").toLowerCase().contains("mac")) {
|
||||
content = content.replace("⌘", "⌃")
|
||||
}
|
||||
val filepath = Paths.get(getContinueGlobalPath(), "continue_tutorial.py").toString()
|
||||
File(filepath).writeText(content)
|
||||
val virtualFile = LocalFileSystem.getInstance().findFileByPath(filepath)
|
||||
|
||||
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
if (virtualFile != null) {
|
||||
FileEditorManager.getInstance(project).openFile(virtualFile, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware {
|
||||
private val coroutineScope = CoroutineScope(Dispatchers.IO)
|
||||
|
||||
|
|
@ -131,24 +153,7 @@ class ContinuePluginStartupActivity : StartupActivity, Disposable, DumbAware {
|
|||
if (!settings.continueState.shownWelcomeDialog) {
|
||||
settings.continueState.shownWelcomeDialog = true
|
||||
// Open continue_tutorial.py
|
||||
ContinuePluginStartupActivity::class.java.getClassLoader().getResourceAsStream("continue_tutorial.py").use { `is` ->
|
||||
if (`is` == null) {
|
||||
throw IOException("Resource not found: continue_tutorial.py")
|
||||
}
|
||||
var content = StreamUtil.readText(`is`, StandardCharsets.UTF_8)
|
||||
if (!System.getProperty("os.name").toLowerCase().contains("mac")) {
|
||||
content = content.replace("⌘", "⌃")
|
||||
}
|
||||
val filepath = Paths.get(getContinueGlobalPath(), "continue_tutorial.py").toString()
|
||||
File(filepath).writeText(content)
|
||||
val virtualFile = LocalFileSystem.getInstance().findFileByPath(filepath)
|
||||
|
||||
if (virtualFile != null) {
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
FileEditorManager.getInstance(project).openFile(virtualFile, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
showTutorial(project)
|
||||
|
||||
// Show the welcome dialog
|
||||
// withContext(Dispatchers.Main) {
|
||||
|
|
|
|||
|
|
@ -116,6 +116,11 @@ class CoreMessenger(continueCorePath: String, ideProtocolClient: IdeProtocolClie
|
|||
writer = OutputStreamWriter(outputStream)
|
||||
reader = BufferedReader(InputStreamReader(inputStream))
|
||||
|
||||
process.onExit().thenRun {
|
||||
val err = process.errorStream.bufferedReader().readText()
|
||||
ideProtocolClient.showMessage("Core process exited with output: $err")
|
||||
}
|
||||
|
||||
Thread {
|
||||
try {
|
||||
while (true) {
|
||||
|
|
|
|||
|
|
@ -706,7 +706,7 @@ class IdeProtocolClient (
|
|||
return fileEditorManager.openFiles.toList().map { it.path }
|
||||
}
|
||||
|
||||
private fun showMessage(msg: String) {
|
||||
fun showMessage(msg: String) {
|
||||
val statusBar = WindowManager.getInstance().getStatusBar(project)
|
||||
|
||||
JBPopupFactory.getInstance()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.continuedev.continueintellijextension.toolWindow
|
||||
|
||||
import com.github.continuedev.continueintellijextension.activities.showTutorial
|
||||
import com.github.continuedev.continueintellijextension.constants.getConfigJsonPath
|
||||
import com.github.continuedev.continueintellijextension.`continue`.*
|
||||
import com.github.continuedev.continueintellijextension.factories.CustomSchemeHandlerFactory
|
||||
|
|
@ -152,6 +153,9 @@ class ContinuePluginToolWindowFactory : ToolWindowFactory, DumbAware {
|
|||
|
||||
),"#00ff0022")
|
||||
}
|
||||
"showTutorial" -> {
|
||||
showTutorial(project)
|
||||
}
|
||||
"showVirtualFile" -> {
|
||||
val data = data.asJsonObject
|
||||
ide?.showVirtualFile(data.get("name").asString, data.get("content").asString)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue