{"html_url": "https://github.com/simonw/sqlite-utils/issues/433#issuecomment-1640826795", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/433", "id": 1640826795, "node_id": "IC_kwDOCGYnMM5hzQer", "user": {"value": 76528036, "label": "J450n-4-W"}, "created_at": "2023-07-18T19:08:50Z", "updated_at": "2023-07-18T19:08:50Z", "author_association": "NONE", "body": "Came here to report this, but instead I'll confirm the issue across two terminal emulators (Gnome Terminal and Alacritty) on Pop_OS! 22.04 (currently based on Ubuntu/Gnome). Also messes up the formatting of the terminal. Can also confirm that reset fixes it until the next sqlite-utils command. ", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1239034903, "label": "CLI eats my cursor"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/433#issuecomment-1578840450", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/433", "id": 1578840450, "node_id": "IC_kwDOCGYnMM5eGzGC", "user": {"value": 392720, "label": "jonafato"}, "created_at": "2023-06-06T14:09:04Z", "updated_at": "2023-06-06T14:09:04Z", "author_association": "NONE", "body": "I also ran into this recently. See below for a patch for one possible solution (tested via \"it works on my machine\", but I don't expect that this behavior would vary a whole lot across terminal emulators and shells). Another possible solution might be to subclass click's `ProgressBar` to keep the logic within the original context manager. Happy to send a PR or for this patch to serve as the basis for a fix that someone else authors.\r\n\r\n```patch\r\ndiff --git a/sqlite_utils/utils.py b/sqlite_utils/utils.py\r\nindex 06c1a4c..530a3a3 100644\r\n--- a/sqlite_utils/utils.py\r\n+++ b/sqlite_utils/utils.py\r\n@@ -147,14 +147,23 @@ def decode_base64_values(doc):\r\n \r\n \r\n class UpdateWrapper:\r\n- def __init__(self, wrapped, update):\r\n+ def __init__(self, wrapped, update, render_finish):\r\n self._wrapped = wrapped\r\n self._update = update\r\n+ self._render_finish = render_finish\r\n \r\n def __iter__(self):\r\n- for line in self._wrapped:\r\n- self._update(len(line))\r\n- yield line\r\n+ return self\r\n+\r\n+ def __next__(self):\r\n+ try:\r\n+ line = next(self._wrapped)\r\n+ except StopIteration as e:\r\n+ self._render_finish()\r\n+ raise\r\n+\r\n+ self._update(len(line))\r\n+ return line\r\n \r\n def read(self, size=-1):\r\n data = self._wrapped.read(size)\r\n@@ -178,7 +187,7 @@ def file_progress(file, silent=False, **kwargs):\r\n else:\r\n file_length = os.path.getsize(file.name)\r\n with click.progressbar(length=file_length, **kwargs) as bar:\r\n- yield UpdateWrapper(file, bar.update)\r\n+ yield UpdateWrapper(file, bar.update, bar.render_finish)\r\n \r\n \r\n class Format(enum.Enum):\r\n\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1239034903, "label": "CLI eats my cursor"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/433#issuecomment-1416486796", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/433", "id": 1416486796, "node_id": "IC_kwDOCGYnMM5Ubd-M", "user": {"value": 16236421, "label": "alecstein"}, "created_at": "2023-02-03T22:32:10Z", "updated_at": "2023-02-03T22:32:10Z", "author_association": "NONE", "body": "Came here to say that I also have this issue.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1239034903, "label": "CLI eats my cursor"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/433#issuecomment-1139484453", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/433", "id": 1139484453, "node_id": "IC_kwDOCGYnMM5D6ycl", "user": {"value": 4068, "label": "frafra"}, "created_at": "2022-05-27T10:20:08Z", "updated_at": "2022-05-27T10:20:08Z", "author_association": "NONE", "body": "I can confirm. This only happens with sqlite-utils. I am using gnome-terminal with bash.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1239034903, "label": "CLI eats my cursor"}, "performed_via_github_app": null}