27 Commits

Author SHA1 Message Date
Anthony Sottile
c4cba4a884 Merge pull request #172 from asottile/all-repos_autofix_gh-funding-default
Use org-default .github/FUNDING.yml
2021-11-23 11:53:51 -05:00
Anthony Sottile
38faec4519 Use org-default .github/FUNDING.yml
Committed via https://github.com/asottile/all-repos
2021-11-23 11:16:13 -05:00
Anthony Sottile
b10afd5bd8 Merge pull request #171 from asottile/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-11-22 17:06:47 -05:00
pre-commit-ci[bot]
b1080319ae [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/add-trailing-comma: v2.2.0 → v2.2.1](https://github.com/asottile/add-trailing-comma/compare/v2.2.0...v2.2.1)
- [github.com/asottile/pyupgrade: v2.29.0 → v2.29.1](https://github.com/asottile/pyupgrade/compare/v2.29.0...v2.29.1)
- [github.com/asottile/setup-cfg-fmt: v1.19.0 → v1.20.0](https://github.com/asottile/setup-cfg-fmt/compare/v1.19.0...v1.20.0)
2021-11-22 21:43:03 +00:00
Anthony Sottile
89dee66711 Merge pull request #170 from asottile/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-11-01 17:24:53 -04:00
pre-commit-ci[bot]
3fb588bba9 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-11-01 21:16:08 +00:00
pre-commit-ci[bot]
99be8b59c9 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/setup-cfg-fmt: v1.18.0 → v1.19.0](https://github.com/asottile/setup-cfg-fmt/compare/v1.18.0...v1.19.0)
2021-11-01 21:15:36 +00:00
Anthony Sottile
d4da5eb800 Merge pull request #169 from asottile/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-10-25 13:48:37 -07:00
pre-commit-ci[bot]
0c3abfc727 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/add-trailing-comma: v2.1.0 → v2.2.0](https://github.com/asottile/add-trailing-comma/compare/v2.1.0...v2.2.0)
2021-10-25 20:21:08 +00:00
Anthony Sottile
c3a34c6262 Merge pull request #168 from asottile/all-repos_autofix_exit-main-2
exit(main()) -> raise SystemExit(main()) pt2
2021-10-24 08:11:16 -07:00
Anthony Sottile
ae30b5763c exit(main()) -> raise SystemExit(main()) pt2
Committed via https://github.com/asottile/all-repos
2021-10-24 07:15:30 -07:00
Anthony Sottile
1cad38d632 Merge pull request #167 from asottile/all-repos_autofix_systemexit-main
replace exit(main()) with raise SystemExit(main())
2021-10-23 11:00:46 -07:00
Anthony Sottile
d2a7014925 replace exit(main()) with raise SystemExit(main())
Committed via https://github.com/asottile/all-repos
2021-10-23 13:22:47 -04:00
Anthony Sottile
9eae3da253 Merge pull request #166 from asottile/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-10-11 13:54:46 -07:00
pre-commit-ci[bot]
075338563e [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-10-11 20:29:12 +00:00
pre-commit-ci[bot]
a7e83ef089 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/PyCQA/flake8: 3.9.2 → 4.0.1](https://github.com/PyCQA/flake8/compare/3.9.2...4.0.1)
- [github.com/asottile/setup-cfg-fmt: v1.17.0 → v1.18.0](https://github.com/asottile/setup-cfg-fmt/compare/v1.17.0...v1.18.0)
- [github.com/pre-commit/mirrors-mypy: v0.910 → v0.910-1](https://github.com/pre-commit/mirrors-mypy/compare/v0.910...v0.910-1)
2021-10-11 20:24:11 +00:00
Anthony Sottile
03656c04bb Merge pull request #165 from asottile/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-10-04 13:28:38 -07:00
pre-commit-ci[bot]
4be3cbff35 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.28.0 → v2.29.0](https://github.com/asottile/pyupgrade/compare/v2.28.0...v2.29.0)
2021-10-04 20:19:23 +00:00
Anthony Sottile
99b3371739 v0.0.24 2021-10-03 18:55:37 -04:00
Anthony Sottile
3c9c6173c3 Merge pull request #164 from AndrewLaneX/replace-errors
Handle errors when replacing
2021-10-03 15:53:22 -07:00
Andrew Lane
84015d3ac4 Handle errors when replacing 2021-10-03 23:45:29 +03:00
Anthony Sottile
d7ffdd1db8 Merge pull request #163 from asottile/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-09-27 13:26:18 -07:00
pre-commit-ci[bot]
4e0c02eaa2 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.26.0 → v2.28.0](https://github.com/asottile/pyupgrade/compare/v2.26.0...v2.28.0)
2021-09-27 20:16:08 +00:00
Anthony Sottile
79919ece2a Merge pull request #162 from asottile/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-09-13 13:30:33 -07:00
pre-commit-ci[bot]
f0ad0e4977 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.25.0 → v2.26.0](https://github.com/asottile/pyupgrade/compare/v2.25.0...v2.26.0)
2021-09-13 20:11:28 +00:00
Anthony Sottile
f18796b78d Merge pull request #161 from asottile/a-italic
A_ITALIC is not always present unlike what's documented
2021-09-12 06:47:05 -07:00
Anthony Sottile
1698533787 A_ITALIC is not always present unlike what's documented 2021-09-12 06:42:28 -07:00
10 changed files with 32 additions and 14 deletions

1
.github/FUNDING.yml vendored
View File

@@ -1 +0,0 @@
github: asottile

View File

@@ -11,7 +11,7 @@ repos:
- id: name-tests-test
- id: requirements-txt-fixer
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies: [flake8-typing-imports==1.7.0]
@@ -25,20 +25,20 @@ repos:
- id: reorder-python-imports
args: [--py3-plus, --add-import, 'from __future__ import annotations']
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.1.0
rev: v2.2.1
hooks:
- id: add-trailing-comma
args: [--py36-plus]
- repo: https://github.com/asottile/pyupgrade
rev: v2.25.0
rev: v2.29.1
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.17.0
rev: v1.20.0
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910
rev: v0.910-1
hooks:
- id: mypy

View File

@@ -3,4 +3,4 @@ from __future__ import annotations
from babi.main import main
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View File

@@ -20,6 +20,8 @@ from babi.user_data import prefix_data
from babi.user_data import xdg_config
from babi.user_data import xdg_data
A_ITALIC = getattr(curses, 'A_ITALIC', 0x80000000) # not always present
class FileSyntax:
include_edge = False
@@ -47,7 +49,7 @@ class FileSyntax:
return (
curses.color_pair(pair) |
curses.A_BOLD * style.b |
curses.A_ITALIC * style.i |
A_ITALIC * style.i |
curses.A_UNDERLINE * style.u
)

View File

@@ -152,4 +152,4 @@ def main(argv: Sequence[str] | None = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View File

@@ -7,6 +7,7 @@ import hashlib
import os
import re
import signal
import sre_parse
import sys
from typing import Generator
from typing import NamedTuple
@@ -419,7 +420,12 @@ class Screen:
'replace with', history='replace', allow_empty=True,
)
if response is not PromptResult.CANCELLED:
self.file.replace(self, search_response, response)
try:
sre_parse.parse_template(response, search_response)
except re.error:
self.status.update('invalid replacement string')
else:
self.file.replace(self, search_response, response)
def command(self) -> EditResult | None:
response = self.prompt('', history='command')

View File

@@ -67,4 +67,4 @@ def main(argv: Sequence[str] | None = None) -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View File

@@ -87,4 +87,4 @@ def main() -> int:
if __name__ == '__main__':
exit(main())
raise SystemExit(main())

View File

@@ -1,6 +1,6 @@
[metadata]
name = babi
version = 0.0.22
version = 0.0.24
description = a text editor
long_description = file: README.md
long_description_content_type = text/markdown
@@ -16,6 +16,7 @@ classifiers =
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
@@ -25,7 +26,7 @@ install_requires =
babi-grammars
identify
onigurumacffi>=0.0.18
importlib_metadata>=1;python_version<"3.8"
importlib-metadata>=1;python_version<"3.8"
windows-curses;sys_platform=="win32"
python_requires = >=3.7

View File

@@ -22,6 +22,16 @@ def test_replace_invalid_regex(run):
h.await_text("invalid regex: '('")
def test_replace_invalid_replacement(run, ten_lines):
with run(str(ten_lines)) as h, and_exit(h):
h.press('^\\')
h.await_text('search (to replace):')
h.press_and_enter('line_0')
h.await_text('replace with:')
h.press_and_enter('\\')
h.await_text('invalid replacement string')
def test_replace_cancel_at_replace_string(run):
with run() as h, and_exit(h):
h.press('^\\')