@@ -12,6 +12,10 @@ import SwiftyJSON
1212
1313class SourceEditorCommand : NSObject , XCSourceEditorCommand {
1414
15+ let jumpToSelectionMessage : JSON = [
16+ " id " : " jumpToSelection "
17+ ]
18+
1519 lazy var connection : NSXPCConnection = {
1620 let connection = NSXPCConnection ( serviceName: " com.ol.VoiceCodeXCSourceEditorExtensionApp.VoiceCodeSourceEditorExtension.VoiceCodeXPCService " )
1721 connection. remoteObjectInterface = NSXPCInterface ( with: VoiceCodeXPCServiceProtocol . self)
@@ -174,26 +178,26 @@ class SourceEditorCommand: NSObject, XCSourceEditorCommand {
174178 // MARK: Editor overrides
175179 case " editor:move-to-line-number " :
176180 buffer. selections [ 0 ] = makeRange ( startLine: line, endLine: line, nLinesInBuffer: nLinesInBuffer)
177- service. sendMessage ( message: " { \" id \" : \" jumpToSelection \" } " )
181+ service. sendMessage ( message: jumpToSelectionMessage . rawString ( ) ! )
178182 break
179183 case " editor:move-to-line-number-and-way-right " :
180184 let lineLength = getLineLength ( lineNumber: line, nLinesInBuffer: nLinesInBuffer, buffer: buffer)
181185 buffer. selections [ 0 ] = makeRange ( startLine: line, endLine: line, nLinesInBuffer: nLinesInBuffer, startColumn: lineLength - 1 , endColumn: lineLength - 1 , numberOfColumnsInLine: lineLength)
182- service. sendMessage ( message: " { \" id \" : \" jumpToSelection \" } " )
186+ service. sendMessage ( message: jumpToSelectionMessage . rawString ( ) ! )
183187 break
184188 case " editor:move-to-line-number-and-way-left " :
185189 let lineLength = getLineLength ( lineNumber: line, nLinesInBuffer: nLinesInBuffer, buffer: buffer)
186190
187191 buffer. selections [ 0 ] = makeRange ( startLine: line, endLine: line, nLinesInBuffer: nLinesInBuffer, startColumn: 0 , endColumn: 0 , numberOfColumnsInLine: lineLength)
188- service. sendMessage ( message: " { \" id \" : \" jumpToSelection \" } " )
192+ service. sendMessage ( message: jumpToSelectionMessage . rawString ( ) ! )
189193 break
190194 case " editor:insert-under-line-number " :
191195 buffer. lines. insert ( " " , at: line)
192196 break
193197 case " editor:select-line-number " :
194198 let lineLength = getLineLength ( lineNumber: line, nLinesInBuffer: nLinesInBuffer, buffer: buffer)
195199 buffer. selections [ 0 ] = makeRange ( startLine: line, endLine: line, nLinesInBuffer: nLinesInBuffer, startColumn: 0 , endColumn: lineLength, numberOfColumnsInLine: lineLength)
196- service. sendMessage ( message: " { \" id \" : \" jumpToSelection \" } " )
200+ service. sendMessage ( message: jumpToSelectionMessage . rawString ( ) ! )
197201 break
198202 case " editor:expand-selection-to-scope " :
199203 //MARK: TODO: editor:expand-selection-to-scope
@@ -206,7 +210,7 @@ class SourceEditorCommand: NSObject, XCSourceEditorCommand {
206210 let lineLength = getLineLength ( lineNumber: lastLine, nLinesInBuffer: nLinesInBuffer, buffer: buffer)
207211
208212 buffer. selections [ 0 ] = makeRange ( startLine: line, endLine: lastLine, nLinesInBuffer: nLinesInBuffer, startColumn: 0 , endColumn: lineLength, numberOfColumnsInLine: lineLength)
209- service. sendMessage ( message: " { \" id \" : \" jumpToSelection \" } " )
213+ service. sendMessage ( message: jumpToSelectionMessage . rawString ( ) ! )
210214 break
211215 case " editor:extend-selection-to-line-number " :
212216 let currentSelectionRange = buffer. selections [ 0 ] as! XCSourceTextRange
0 commit comments