Skip to content

Commit 3046ae0

Browse files
authored
Merge pull request #64 from GeekTree0101/bug/link-insertion-logic-improvement
Jump to next location after link insert
2 parents ebd768c + 35b348f commit 3046ae0

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

VEditorKit/Classes/VEditorNode.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,9 @@ open class VEditorNode: ASDisplayNode, ASTableDelegate, ASTableDataSource {
304304
guard let range = self.activeTextNode?.selectedRange,
305305
let attr = self.editorRule.linkAttribute(url) else { return }
306306
self.activeTextNode?.textStorage?.setAttributes(attr, range: range)
307+
let nextLocation = range.location + range.length + 1
308+
// NOTE: selectedRange doesn't occur out of bounds crash :) don't worry
309+
self.activeTextNode?.selectedRange = .init(location: nextLocation, length: 0)
307310
}
308311

309312
/**

0 commit comments

Comments
 (0)