Whole file
advice-animal/imperfect
The author described this change as “Fix (and test) set_value on multiline strings”. It counts as a record because the check below fails on the code as it stood at ba55d4836 and passes on 2c9d6c88d, with nothing else changed between the two runs.
Projectadvice-animal/imperfect
Fix saved2020-03-08
Sharing licenceMIT · LICENSE
Change size+12 −8
What the code was meant to do, written into the code itself as a save note
Fix (and test) set_value on multiline strings
The change
| 92 | 92 | return False | |
| 93 | 93 | ||
| 94 | 94 | def set_value(self, key: str, value: str) -> None: | |
| 95 | - | new_valueline = ValueLine( | |
| 96 | - | text=value, | |
| 97 | - | newline="\n", | |
| 98 | - | whitespace_before_text="", | |
| 99 | - | whitespace_after_text="", | |
| 100 | - | ) | |
| 95 | + | valuelines = [ | |
| 96 | + | ValueLine( | |
| 97 | + | text=line, | |
| 98 | + | newline="\n", | |
| 99 | + | whitespace_before_text=" " if i > 0 else "", | |
| 100 | + | whitespace_after_text="", | |
| 101 | + | ) | |
| 102 | + | for i, line in enumerate(value.splitlines(False)) | |
| 103 | + | ] | |
| 104 | + | ||
| 101 | 105 | for e in self.entries: | |
| 102 | 106 | if e.key.lower() == key: | |
| 103 | - | e.value = [new_valueline] | |
| 107 | + | e.value = valuelines | |
| 104 | 108 | break | |
| 105 | 109 | else: | |
| 106 | 110 | self.entries.append( | |
| 107 | 111 | ConfigEntry( | |
| 108 | 112 | key=key, | |
| 109 | 113 | equals="=", | |
| 110 | - | value=[new_valueline], | |
| 114 | + | value=valuelines, | |
| 111 | 115 | whitespace_before_equals=" ", | |
| 112 | 116 | whitespace_before_value=" ", | |
| 113 | 117 | ) |
The check that tells the two apart
fail→pass·imperfect/tests/editing.py::EditingTest::test_multiline_value
Check file imperfect/tests/editing.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before itba55d4836ee4fe4cdbb40952da5c643b81895775
Broken version dated2020-02-25
Moduleimperfect.types
Units changedConfigSection
Fingerprinte2ba8ac2ab587c36
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.