MCPcopy Create free account
hub / github.com/microsoft/SandDance / insertString

Function insertString

docs/app/js/sanddance-app.js:50919–50941  ·  view source on GitHub ↗
(maskCharData, selectionStart, newString)

Source from the content-addressed store, hash-verified

50917 return maskCharData;
50918}
50919function insertString(maskCharData, selectionStart, newString) {
50920 var stringIndex = 0;
50921 var nextIndex = 0;
50922 var isStringInserted = false;
50923 // Iterate through _maskCharData finding values with a displayIndex after the specified range start
50924 for(var i = 0; i < maskCharData.length && stringIndex < newString.length; i++)if (maskCharData[i].displayIndex >= selectionStart) {
50925 isStringInserted = true;
50926 nextIndex = maskCharData[i].displayIndex;
50927 // Find the next character in the newString that matches the format
50928 while(stringIndex < newString.length){
50929 // If the character matches the format regexp, set the maskCharData to the new character
50930 if (maskCharData[i].format.test(newString.charAt(stringIndex))) {
50931 maskCharData[i].value = newString.charAt(stringIndex++);
50932 // Set the nextIndex to the display index of the next mask format character.
50933 if (i + 1 < maskCharData.length) nextIndex = maskCharData[i + 1].displayIndex;
50934 else nextIndex++;
50935 break;
50936 }
50937 stringIndex++;
50938 }
50939 }
50940 return isStringInserted ? nextIndex : selectionStart;
50941}
50942
50943},{"@parcel/transformer-js/src/esmodule-helpers.js":"jA2du"}],"hbvPy":[function(require,module,exports) {
50944var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected