diff --git a/manimlib/mobject/svg/string_mobject.py b/manimlib/mobject/svg/string_mobject.py index c393019a..08a3c73d 100644 --- a/manimlib/mobject/svg/string_mobject.py +++ b/manimlib/mobject/svg/string_mobject.py @@ -36,7 +36,7 @@ class StringMobject(SVGMobject, ABC): or a 2-tuple containing integers or None, or a collection of the above. Note, substrings specified cannot *partly* overlap with each other. - Each instance of `StringMobject` generates 2 svg files. + Each instance of `StringMobject` may generate 2 svg files. The additional one is generated with some color commands inserted, so that each submobject of the original `SVGMobject` will be labelled by the color of its paired submobject from the additional `SVGMobject`. @@ -546,15 +546,11 @@ class StringMobject(SVGMobject, ABC): ]) def select_parts(self, selector: Selector) -> VGroup: - indices_list = self.get_submob_indices_lists_by_selector(selector) - if indices_list: - return self.build_parts_from_indices_lists(indices_list) - elif isinstance(selector, str): - # Otherwise, try finding substrings which weren't specifically isolated - log.warning("Accessing unisolated substring, results may not be as expected") + specified_substrings = self.get_specified_substrings() + if isinstance(selector, str) and selector not in specified_substrings: return self.select_unisolated_substring(selector) - else: - return VGroup() + indices_list = self.get_submob_indices_lists_by_selector(selector) + return self.build_parts_from_indices_lists(indices_list) def __getitem__(self, value: int | slice | Selector) -> VMobject: if isinstance(value, (int, slice)):