1- import SuggestionBasic
21import Foundation
2+ import SuggestionBasic
33import XcodeKit
44import XPCShared
55
@@ -19,16 +19,21 @@ extension XCSourceEditorCommandInvocation {
1919 }
2020
2121 func accept( _ updatedContent: UpdatedContent ) {
22- if let newSelection = updatedContent. newSelection {
22+ if ! updatedContent. newSelections . isEmpty {
2323 mutateCompleteBuffer (
2424 modifications: updatedContent. modifications,
2525 restoringSelections: false
2626 )
2727 buffer. selections. removeAllObjects ( )
28- buffer. selections. add ( XCSourceTextRange (
29- start: . init( line: newSelection. start. line, column: newSelection. start. character) ,
30- end: . init( line: newSelection. end. line, column: newSelection. end. character)
31- ) )
28+ for newSelection in updatedContent. newSelections {
29+ buffer. selections. add ( XCSourceTextRange (
30+ start: . init(
31+ line: newSelection. start. line,
32+ column: newSelection. start. character
33+ ) ,
34+ end: . init( line: newSelection. end. line, column: newSelection. end. character)
35+ ) )
36+ }
3237 } else {
3338 mutateCompleteBuffer (
3439 modifications: updatedContent. modifications,
@@ -47,17 +52,17 @@ extension EditorContent {
4752 uti: buffer. contentUTI,
4853 cursorPosition: ( ( buffer. selections. lastObject as? XCSourceTextRange ) ? . end) . map {
4954 CursorPosition ( line: $0. line, character: $0. column)
50- } ?? CursorPosition ( line: 0 , character: 0 ) ,
55+ } ?? CursorPosition ( line: 0 , character: 0 ) ,
5156 cursorOffset: - 1 ,
5257 selections: buffer. selections. map {
5358 let sl = ( $0 as? XCSourceTextRange ) ? . start. line ?? 0
5459 let sc = ( $0 as? XCSourceTextRange ) ? . start. column ?? 0
5560 let el = ( $0 as? XCSourceTextRange ) ? . end. line ?? 0
5661 let ec = ( $0 as? XCSourceTextRange ) ? . end. column ?? 0
57-
62+
5863 return Selection (
59- start: CursorPosition ( line: sl, character: sc ) ,
60- end: CursorPosition ( line: el, character: ec )
64+ start: CursorPosition ( line: sl, character: sc) ,
65+ end: CursorPosition ( line: el, character: ec)
6166 )
6267 } ,
6368 tabSize: buffer. tabWidth,
@@ -96,3 +101,4 @@ extension Task where Failure == Error {
96101private struct TimeoutError : LocalizedError {
97102 var errorDescription : String ? = " Task timed out before completion "
98103}
104+
0 commit comments