@@ -20,32 +20,28 @@ class EditCodeSubmissionHandler(
20
20
private val previousSourceRef = AtomicReference <String ?>(null )
21
21
22
22
suspend fun handleSubmit (userPrompt : String ) {
23
- try {
24
- observableProperties.loading.set(true )
25
- observableProperties.submitted.set(true )
23
+ observableProperties.loading.set(true )
24
+ observableProperties.submitted.set(true )
26
25
27
- previousSourceRef.getAndSet(editor.document.text)
28
- val (selectionTextRange, selectedText) = readAction {
29
- editor.selectionModel.run {
30
- Pair (
31
- TextRange (selectionStart, selectionEnd),
32
- editor.selectionModel.selectedText ? : " "
33
- )
34
- }
26
+ previousSourceRef.getAndSet(editor.document.text)
27
+ val (selectionTextRange, selectedText) = readAction {
28
+ editor.selectionModel.run {
29
+ Pair (
30
+ TextRange (selectionStart, selectionEnd),
31
+ editor.selectionModel.selectedText ? : " "
32
+ )
35
33
}
36
- runInEdt { editor.selectionModel.removeSelection() }
37
-
38
- // TODO: Support other providers
39
- CompletionClientProvider .getCodeGPTClient().getChatCompletionAsync(
40
- CompletionRequestProvider .buildEditCodeRequest(
41
- " $userPrompt \n\n $selectedText " ,
42
- service<CodeGPTServiceSettings >().state.chatCompletionSettings.model
43
- ),
44
- EditCodeCompletionListener (editor, observableProperties, selectionTextRange)
45
- )
46
- } finally {
47
- observableProperties.loading.set(false )
48
34
}
35
+ runInEdt { editor.selectionModel.removeSelection() }
36
+
37
+ // TODO: Support other providers
38
+ CompletionClientProvider .getCodeGPTClient().getChatCompletionAsync(
39
+ CompletionRequestProvider .buildEditCodeRequest(
40
+ " $userPrompt \n\n $selectedText " ,
41
+ service<CodeGPTServiceSettings >().state.chatCompletionSettings.model
42
+ ),
43
+ EditCodeCompletionListener (editor, observableProperties, selectionTextRange)
44
+ )
49
45
}
50
46
51
47
fun handleAccept () {
0 commit comments