@@ -159,13 +159,25 @@ extension TextView: NSDraggingSource {
159159 }
160160
161161 override public func draggingEntered( _ sender: any NSDraggingInfo ) -> NSDragOperation {
162- let canReadObjects = sender. draggingPasteboard. canReadObject ( forClasses: pasteboardObjects)
162+ determineDragOperation ( sender)
163+ }
164+
165+ override public func draggingUpdated( _ sender: any NSDraggingInfo ) -> NSDragOperation {
166+ determineDragOperation ( sender)
167+ }
168+
169+ private func determineDragOperation( _ dragInfo: any NSDraggingInfo ) -> NSDragOperation {
170+ let canReadObjects = dragInfo. draggingPasteboard. canReadObject ( forClasses: pasteboardObjects)
163171
164- if canReadObjects {
172+ guard canReadObjects else {
173+ return NSDragOperation ( )
174+ }
175+
176+ if let currentEvent = NSApplication . shared. currentEvent, currentEvent. modifierFlags. contains ( . option) {
165177 return . copy
166178 }
167179
168- return NSDragOperation ( )
180+ return . move
169181 }
170182
171183 override public func performDragOperation( _ sender: any NSDraggingInfo ) -> Bool {
@@ -190,8 +202,11 @@ extension TextView: NSDraggingSource {
190202 return false
191203 }
192204
205+ let shouldCutSourceText = !( NSApplication . shared. currentEvent? . modifierFlags. contains ( . option) ?? false )
206+
193207 undoManager? . beginUndoGrouping ( )
194- if let source = sender. draggingSource as? TextView , source === self {
208+
209+ if shouldCutSourceText, let source = sender. draggingSource as? TextView , source === self {
195210 // Offset the insertion location so that we can remove the text first before pasting it into the editor.
196211 var updatedInsertionOffset = insertionOffset
197212 for selection in source. selectionManager. textSelections. reversed ( )
0 commit comments