Skip to content

SegmentOperations write paths: set_String on ITsString.BaselineText (sibling of #170, 8 sites) #172

@MattGyverLee

Description

@MattGyverLee

Context

Companion to #170. ISegment.BaselineText is ITsString (confirmed: liblcm/src/SIL.LCModel/InterfaceAdditions.cs:542 declares ITsString BaselineText { get; } — a read-only virtual computed property derived from ((IStTxtPara)Owner).Contents.GetSubstring(BeginOffset, EndOffset) per OverridesCellar.cs:4397).

#170 fixed the read path (GetBaselineText). The write paths in the same file have the same root-cause bug — they call .set_String(ws, mkstr) on an ITsString as if it were IMultiString.

Two problems compound here:

  1. ITsString has no .set_String method → AttributeError at runtime
  2. Even if it did, BaselineText is a computed, read-only property with no backing store — writes would have nothing to persist to. The backing store is IStTxtPara.Contents; correct edits must rewrite the paragraph's contents with the segment range replaced (or use LCM's ParagraphParser / AnalysisAdjuster services).

Affected sites (flexlibs2/code/TextsWords/SegmentOperations.py)

Line Method Pattern
279 SetBaselineText segment_obj.BaselineText.set_String(ws, mkstr)
523 Create segment.BaselineText.set_String(ws, mkstr)
688 GetSyncableProperties GetMultiStringDict(item.BaselineText) — IMultiString helper called on ITsString
887 SplitSegment (first segment) first_segment.BaselineText.set_String(...)
894 SplitSegment (second segment) second_segment.BaselineText.set_String(...)
974 MergeSegments (first call) merged_segment.BaselineText.set_String(...)
987 MergeSegments (second call) merged_segment.BaselineText.set_String(...)
1359 RebuildSegments segment.BaselineText.set_String(...)

Source

Domain audit during work on #170 / #171 (2026-05-30). Sweep covered all segment*.BaselineText.set_String and GetMultiStringDict(.*BaselineText) occurrences in the file.

Suggested fix shape (for the eventual cycle)

  • Route segment-text edits through IStTxtPara.Contents (e.g., assemble a new ITsString for Contents with the segment range replaced via ITsStrBldr), then trigger LCM's segment re-derivation.
  • For GetSyncableProperties: serialize BaselineText as a plain string (no WS dictionary), since it has no WS axis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions