@@ -113,11 +113,11 @@ impl Pen {
113113 }
114114 }
115115 // If we've got the end of a contour selected we'll continue drawing that contour.
116- else if let Some ( contour_idx) = v. contour_idx {
116+ else if let ( Some ( contour_idx) , Some ( point_idx ) ) = ( v. contour_idx , v . point_idx ) {
117117 let mouse_pos = mouse_info. position ;
118118 let contour_len = get_contour_len ! ( v. get_active_layer_ref( ) , contour_idx) ;
119119
120- if v . point_idx . unwrap ( ) == contour_len - 1 {
120+ if point_idx == contour_len - 1 {
121121 v. point_idx = {
122122 let layer = v. get_active_layer_mut ( ) ;
123123 get_contour ! ( layer, contour_idx) . push ( Point :: from_x_y_type (
@@ -129,7 +129,7 @@ impl Pen {
129129 layer. outline [ contour_idx] . operation . insert_op ( & contour, contour_len) ;
130130 Some ( get_contour_len ! ( layer, contour_idx) - 1 )
131131 } ;
132- } else if v . point_idx . unwrap ( ) == 0 {
132+ } else if point_idx == 0 {
133133 {
134134 let layer = v. get_active_layer_mut ( ) ;
135135 let point_type = get_point ! ( layer, contour_idx, 0 ) . ptype ;
@@ -146,6 +146,12 @@ impl Pen {
146146 layer. outline [ contour_idx] . operation . insert_op ( & contour, 0 ) ;
147147 } ;
148148 v. end_modification ( ) ;
149+ } else { // force a deselect and redo the event. Cf. GitHub issue №337.
150+ v. cancel_modification ( ) ;
151+ v. contour_idx = None ;
152+ v. point_idx = None ;
153+ v. selected . clear ( ) ;
154+ return self . mouse_pressed ( v, i, mouse_info) ;
149155 }
150156 } else {
151157 // Lastly if we get here we create a new contour.
@@ -169,7 +175,7 @@ impl Pen {
169175 }
170176
171177 // No matter how you move the point we want you to be able to manipulate it so we push the MoveHandle
172- // vehavior onto the editor's behavior stack.
178+ // behavior onto the editor's behavior stack.
173179 v. push_behavior ( Box :: new ( MoveHandle :: new ( WhichHandle :: A , mouse_info, true ) ) ) ;
174180 }
175181
0 commit comments