@@ -2931,22 +2931,12 @@ pub(crate) fn apply_inherited_text_properties(
29312931 return ;
29322932 }
29332933
2934- let ( props, existing_keys ) = buffers
2934+ let props = buffers
29352935 . get ( current_id)
29362936 . map ( |buf| {
2937- let merged = super :: misc_eval:: inherited_text_properties_for_inserted_range_in_state (
2937+ super :: misc_eval:: inherited_text_properties_for_inserted_range_in_state (
29382938 obarray, dynamic, buf, old_pt, text_len,
2939- ) ;
2940- // Properties already present on the just-inserted region (from the
2941- // source string's own propertize plist). Source properties win
2942- // over inherited ones, matching GNU graft_intervals_into_buffer.
2943- let existing: std:: collections:: HashSet < Value > = buf
2944- . text
2945- . text_props_get_properties_ordered ( old_pt)
2946- . into_iter ( )
2947- . map ( |( name, _) | name)
2948- . collect ( ) ;
2949- ( merged, existing)
2939+ )
29502940 } )
29512941 . unwrap_or_default ( ) ;
29522942 if props. is_empty ( ) {
@@ -2956,9 +2946,6 @@ pub(crate) fn apply_inherited_text_properties(
29562946 // put_property prepends new properties to interval order, so apply the
29572947 // merged GNU plist in reverse to preserve the final plist shape.
29582948 for ( name, value) in props. iter ( ) . rev ( ) {
2959- if existing_keys. contains ( name) {
2960- continue ;
2961- }
29622949 let _ =
29632950 buffers. put_buffer_text_property ( current_id, old_pt, old_pt + text_len, * name, * value) ;
29642951 }
@@ -3062,20 +3049,19 @@ fn insert_pieces_in_state(
30623049 if let Some ( str_table) = piece. text_props {
30633050 let _ = buffers. append_buffer_text_properties ( current_id, & str_table, insert_pos) ;
30643051 }
3065- // Match GNU adjust_intervals_for_insertion (intervals.c:802): every
3066- // insert applies sticky-aware inheritance from the surrounding
3067- // intervals, regardless of whether `insert-and-inherit` was used.
3068- // Source-string properties already applied above take precedence
3069- // because apply_inherited_text_properties skips keys already present.
3070- let _ = inherit;
3071- apply_inherited_text_properties (
3072- obarray,
3073- dynamic,
3074- buffers,
3075- current_id,
3076- insert_pos,
3077- piece. text . sbytes ( ) ,
3078- ) ;
3052+ if inherit {
3053+ // GNU clears surrounding inherited properties for plain `insert`
3054+ // after interval adjustment; only the inheriting insert variants
3055+ // keep sticky properties from adjoining text.
3056+ apply_inherited_text_properties (
3057+ obarray,
3058+ dynamic,
3059+ buffers,
3060+ current_id,
3061+ insert_pos,
3062+ piece. text . sbytes ( ) ,
3063+ ) ;
3064+ }
30793065 }
30803066 Ok ( Value :: NIL )
30813067}
0 commit comments