@@ -109,17 +109,22 @@ def mapping_send(self, args):
109109 @neovim .function ("IronSendMotion" , range = True )
110110 def send_motion_to_repl (self , args , rng = None ):
111111 logger .debug ("Supplied data: {}" .format (", " .join (args )))
112+ cur_buf = self .nvim .current .buffer
113+
114+ if not 'iron_cursor_pos' in cur_buf .vars :
115+ # Probably repeating, so setting the position manually
116+ cur_buf .vars ['iron_cursor_pos' ] = self .call ('winsaveview' )
112117
113118 if args [0 ] == 'visual' :
114- init = self . nvim . current . buffer .mark ('<' )
115- end = self . nvim . current . buffer .mark ('>' )
119+ init = cur_buf .mark ('<' )
120+ end = cur_buf .mark ('>' )
116121 else :
117- init = self . nvim . current . buffer .mark ('[' )
118- end = self . nvim . current . buffer .mark (']' )
122+ init = cur_buf .mark ('[' )
123+ end = cur_buf .mark (']' )
119124
120125 end [1 ] += 1
121126
122- text = self . nvim . current . buffer [init [0 ]- 1 :end [0 ]]
127+ text = cur_buf [init [0 ]- 1 :end [0 ]]
123128
124129 logger .debug ("Gathered: {} - {}: {}" .format (
125130 init , end , "\n " .join (text )))
@@ -133,6 +138,9 @@ def send_motion_to_repl(self, args, rng=None):
133138
134139 logger .debug ("Stripped: {}" .format ("\n " .join (text )))
135140
141+ self .call ('winrestview' , cur_buf .vars ['iron_cursor_pos' ])
142+ del cur_buf .vars ['iron_cursor_pos' ]
143+
136144 return self .send_to_repl (["\n " .join (text )])
137145
138146 @neovim .function ("IronSend" )
0 commit comments