Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99b3371739 | ||
|
|
3c9c6173c3 | ||
|
|
84015d3ac4 | ||
|
|
d7ffdd1db8 | ||
|
|
4e0c02eaa2 | ||
|
|
79919ece2a | ||
|
|
f0ad0e4977 | ||
|
|
f18796b78d | ||
|
|
1698533787 |
@@ -30,7 +30,7 @@ repos:
|
||||
- id: add-trailing-comma
|
||||
args: [--py36-plus]
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v2.25.0
|
||||
rev: v2.28.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py37-plus]
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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('^\\')
|
||||
|
||||
Reference in New Issue
Block a user