File tree Expand file tree Collapse file tree 2 files changed +26
-17
lines changed
core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/code
exts/ext-dependencies/src/233/main/kotlin/cc/unitmesh/dependencies Expand file tree Collapse file tree 2 files changed +26
-17
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import com.intellij.openapi.actionSystem.DataProvider
14
14
import com.intellij.openapi.application.ApplicationManager
15
15
import com.intellij.openapi.application.ReadAction
16
16
import com.intellij.openapi.command.WriteCommandAction
17
+ import com.intellij.openapi.diagnostic.logger
17
18
import com.intellij.openapi.editor.Document
18
19
import com.intellij.openapi.editor.Editor
19
20
import com.intellij.openapi.editor.EditorFactory
@@ -143,7 +144,11 @@ open class CodeHighlightSketch(
143
144
144
145
val document = editorFragment?.editor?.document
145
146
val normalizedText = StringUtil .convertLineSeparators(text)
146
- document?.replaceString(0 , document.textLength, normalizedText)
147
+ try {
148
+ document?.replaceString(0 , document.textLength, normalizedText)
149
+ } catch (e: Throwable ) {
150
+ logger<CodeHighlightSketch >().error(" Error updating editor text" , e)
151
+ }
147
152
148
153
val lineCount = document?.lineCount ? : 0
149
154
if (lineCount > editorLineThreshold) {
Original file line number Diff line number Diff line change @@ -28,22 +28,26 @@ class DependenciesFunctionProvider : ToolchainFunctionProvider {
28
28
val future = CompletableFuture <String >()
29
29
val task = object : Task .Backgroundable (project, " Processing context" , false ) {
30
30
override fun run (indicator : ProgressIndicator ) {
31
- val deps: List <Package > = runReadAction {
32
- ProjectDependenciesModel .supportedModels(project).map {
33
- modules.map { module ->
34
- it.declaredDependencies(module)
35
- }.flatten()
36
- }.flatten().map {
37
- it.pkg
38
- }
39
- }
40
-
41
- val result = " Here is the project dependencies:\n ```\n " + deps.joinToString(" " ) {
42
- val namespace = it.namespace ? : " "
43
- " $namespace ${it.name} ${it.version} " + " \n "
44
- } + " ```"
45
-
46
- future.complete(result)
31
+ try {
32
+ val deps: List <Package > = runReadAction {
33
+ ProjectDependenciesModel .supportedModels(project).map {
34
+ modules.map { module ->
35
+ it.declaredDependencies(module)
36
+ }.flatten()
37
+ }.flatten().map {
38
+ it.pkg
39
+ }
40
+ }
41
+
42
+ val result = " Here is the project dependencies:\n ```\n " + deps.joinToString(" " ) {
43
+ val namespace = it.namespace ? : " "
44
+ " $namespace ${it.name} ${it.version} " + " \n "
45
+ } + " ```"
46
+
47
+ future.complete(result)
48
+ } catch (e: Exception ) {
49
+ future.completeExceptionally(e)
50
+ }
47
51
}
48
52
}
49
53
You can’t perform that action at this time.
0 commit comments