@@ -700,14 +700,10 @@ export class Configuration {
700700 let langConfig = { ...internalLangConfig } ;
701701
702702 if ( multiLine ) {
703- langConfig . autoClosingPairs = this . mergeConfigProperty (
704- defaultMultiLineConfig . autoClosingPairs ,
705- internalLangConfig ?. autoClosingPairs ,
706- "open"
707- ) ;
703+ langConfig . autoClosingPairs = utils . mergeArraysBy ( defaultMultiLineConfig . autoClosingPairs , internalLangConfig ?. autoClosingPairs , "open" ) ;
708704
709705 // Add the multi-line onEnter rules to the langConfig.
710- langConfig . onEnterRules = this . mergeConfigProperty ( Rules . multilineEnterRules , internalLangConfig ?. onEnterRules , "beforeText" ) ;
706+ langConfig . onEnterRules = utils . mergeArraysBy ( Rules . multilineEnterRules , internalLangConfig ?. onEnterRules , "beforeText" ) ;
711707
712708 // Only assign the default config comments if it doesn't already exist.
713709 // (nullish assignment operator ??=)
@@ -736,15 +732,15 @@ export class Configuration {
736732 if ( isOnEnter && singleLineStyle ) {
737733 // //-style comments
738734 if ( singleLineStyle === "//" ) {
739- langConfig . onEnterRules = this . mergeConfigProperty ( Rules . slashEnterRules , langConfig ?. onEnterRules , "beforeText" ) ;
735+ langConfig . onEnterRules = utils . mergeArraysBy ( Rules . slashEnterRules , langConfig ?. onEnterRules , "beforeText" ) ;
740736 }
741737 // #-style comments
742738 else if ( singleLineStyle === "#" ) {
743- langConfig . onEnterRules = this . mergeConfigProperty ( Rules . hashEnterRules , langConfig ?. onEnterRules , "beforeText" ) ;
739+ langConfig . onEnterRules = utils . mergeArraysBy ( Rules . hashEnterRules , langConfig ?. onEnterRules , "beforeText" ) ;
744740 }
745741 // ;-style comments
746742 else if ( singleLineStyle === ";" ) {
747- langConfig . onEnterRules = this . mergeConfigProperty ( Rules . semicolonEnterRules , langConfig ?. onEnterRules , "beforeText" ) ;
743+ langConfig . onEnterRules = utils . mergeArraysBy ( Rules . semicolonEnterRules , langConfig ?. onEnterRules , "beforeText" ) ;
748744 }
749745 }
750746 // If isOnEnter is false AND singleLineStyle isn't false, i.e. a string.
@@ -854,40 +850,6 @@ export class Configuration {
854850 return vscode . languages . setLanguageConfiguration ( langId , langConfig ) ;
855851 }
856852
857- /**
858- * Merges two configuration properties arrays, removing any duplicates based on a
859- * specified property.
860- *
861- * @param {any[] } defaultConfigProperty The default configuration property array of objects.
862- * @param {any[] } internalConfigProperty The internal configuration property array of objects.
863- * @param {string } objectKey The key within the array item object to check against for preventing duplicates
864- * @returns {any[] } The merged configuration property array without duplicates.
865- */
866- private mergeConfigProperty ( defaultConfigProperty : any [ ] , internalConfigProperty : any [ ] , objectKey : string ) {
867- // Define an empty array if the internalConfigProperty is undefined.
868- internalConfigProperty ??= [ ] ;
869-
870- // Copy to avoid side effects.
871- const merged = [ ...defaultConfigProperty ] ;
872-
873- /**
874- * Merge the arrays and remove any duplicates.
875- */
876-
877- // Loop over the internalConfigProperty array...
878- internalConfigProperty . forEach ( ( item ) =>
879- // Test all items in the merged array, and if the item's
880- // key is not already present in one of the merged array's objects then add the item
881- // to the merged array.
882- //
883- // Code based on "2023 update" portion of this StackOverflow answer:
884- // https://stackoverflow.com/a/1584377/2358222
885- merged . some ( ( mergedItem ) => item [ objectKey ] === mergedItem [ objectKey ] ) ? null : merged . push ( item )
886- ) ;
887-
888- return merged ;
889- }
890-
891853 /**
892854 * The keyboard binding event handler for the single-line blocks on shift+enter.
893855 *
0 commit comments