When opening the Open dialog, it shouldn't populate the file name input,
but when clicking a file, it should fill in the clicked file's name.
The `_expanding_directory_tree` flag gave false positives:
- When opening a file in a directory the program doesn't have permissions to via the CLI,
such as with `python -m src.textual_paint.paint /root/nonexistent`,
opening the Open dialog, and clicking a file, it wasn't populating the filename input,
because the flag was never cleared if it couldn't find (access) the
directories and file matching any of the path parts, working down the directory structure.
This was broken in [b3ca55a3b1] "Use new callback to remove race condition"
but before, it just cleared the flag after a delay, so it wasn't a good solution,
It also gave false negatives:
- When opening the Open dialog, it was populating the name input field
with the file selected programmatically with `expand_to_path`,
instead of leaving it blank.
The automatic expansion was broken in [e9755637d6] "Update Textual to 0.26.0"
due to changes 0.25.0, since directory contents are now loaded in a worker.
This flag's behavior was broken since rewriting the code to handle asynchronous directory loading in
[4e1f11ab23] "Fix expanding directory tree to current folder, in file dialogs"
An alternative I considered was to create a new message such as `EnhancedDirectoryTree.NodeHighlighted`, but let's call it `EnhancedNodeHighlighted`, then to have `on_tree_node_highlighted` in `EnhancedDirectoryTree` which sends `EnhancedNodeHighlighted` always with `from_expand_to_path=False`, and then do:
| # Suppress EnhancedNodeHighlighted with from_expand_to_path=False
| with self.prevent(self.EnhancedNodeHighlighted):
| self.select_node(node)
| # Send it with the flag set
| self.post_message(self.EnhancedNodeHighlighted(..., from_expand_to_path=True))
The solution I settled on was to add an `on_tree_node_highlighted` method to my `EnhancedDirectoryTree` for the purpose of clearing the flag, with still a further delay so that the app's `on_tree_node_highlighted` can use the flag before its cleared.
(I left `_expanding_directory_tree` in at this commit for comparison of the behavior. For a fair estimate of the complexity of this change, include the following cleanup in the diff.)
If digits were present in the document, they were concatenated after
the color codes, and they ran together indistinguishably.
This changed the color index numbers that were read back, to potentially
invalid color indices, and lost the digits as part of the document.
It needs the delimiter of the ending escape code to separate the digits.