MCPcopy Create free account
hub / github.com/chhoumann/MetaEdit / replaceInlineFieldValue

Method replaceInlineFieldValue

src/parser.ts:445–456  ·  view source on GitHub ↗

* Rewrite the value of every inline field named `key` on a single line, * leaving the key, surrounding text, and any `[...]`/`(...)` wrapper intact. * * This is the write-side counterpart to parseInlineContent: because * it reuses the same field boundaries, a full-line va

(line: string, key: string, newValue: string)

Source from the content-addressed store, hash-verified

443 * field matches.
444 */
445 public replaceInlineFieldValue(line: string, key: string, newValue: string): string {
446 const matches = this.parseLineFields(line).filter(field => field.key === key);
447 if (matches.length === 0) return line;
448
449 // Splice right-to-left so each field's offsets stay valid as we rewrite.
450 let result = line;
451 for (let i = matches.length - 1; i >= 0; i--) {
452 const field = matches[i];
453 result = result.slice(0, field.sepEnd) + " " + newValue + result.slice(field.valueEnd);
454 }
455 return result;
456 }
457
458 /**
459 * Rewrite inline field values in raw note content using the same readable-line

Callers 2

replaceInlineFunction · 0.80

Calls 1

parseLineFieldsMethod · 0.95

Tested by 1

replaceInlineFunction · 0.64