Skip to content

Commit ee36c89

Browse files
committed
fix editor:insert-from-line-number
1 parent c84ee7d commit ee36c89

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

SourceEditorExtension/VoiceCodeSourceEditorCommand.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class SourceEditorCommand: NSObject, XCSourceEditorCommand {
4444
case invalidLineNumber
4545
}
4646

47+
//MARK: TODO: for some operations an out of bounds line number should not be clamped
4748
func clampLineNumber(lineNumber: Int, nLinesInBuffer: Int) -> Int {
4849
if(lineNumber < 0) {
4950
return 0
@@ -223,10 +224,10 @@ class SourceEditorCommand: NSObject, XCSourceEditorCommand {
223224
let range = buffer.selections[0] as! XCSourceTextRange
224225
if isInsertionPoint(range: range) {
225226
var currentLine = buffer.lines[range.start.line] as! String
226-
var textToInsert = buffer.lines[line] as! String //TODO: if line is out of range nothing should happen here
227+
var textToInsert = buffer.lines[line] as! String //MARK: TODO: if line is out of range nothing should happen here
227228
let insertIndex = currentLine.index(currentLine.startIndex, offsetBy: range.start.column)
228229
currentLine.insert(contentsOf: textToInsert.characters, at: insertIndex)
229-
currentLine.remove(at: currentLine.endIndex) //TODO: check thisworks...delete new line
230+
currentLine.remove(at: currentLine.index(currentLine.endIndex, offsetBy: -1))
230231
buffer.lines.replaceObject(at: range.start.line, with: currentLine)
231232
}
232233
break

0 commit comments

Comments
 (0)