Skip to content

Commit 1e31253

Browse files
feat: add modify edit range feature in pyo3
1 parent d81c6c3 commit 1e31253

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

crates/pyo3/src/py_node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ fn get_matcher_from_rule(
371371
Ok(matcher)
372372
}
373373

374-
#[pyclass(frozen, get_all)]
374+
#[pyclass(get_all, set_all)]
375375
#[derive(Clone, PartialEq, Eq, Hash)]
376376
pub struct Edit {
377377
/// The char position of the edit

crates/pyo3/tests/test_fix.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,15 @@ def test_change_unicode():
3838
nodes = root.find_all(kind="identifier")
3939
edits = [node.replace('114514') for node in nodes]
4040
s = root.commit_edits(edits)
41-
assert s == "114514 = 114514(114514)"
41+
assert s == "114514 = 114514(114514)"
42+
43+
def test_modified_fix():
44+
sg = SgRoot('いいよ = log(514)', "javascript")
45+
root = sg.root()
46+
node = root.find(kind="number")
47+
assert node
48+
edit = node.replace('こいよ')
49+
edit.position -= 1
50+
edit.deleted_length += 2
51+
s = root.commit_edits([edit])
52+
assert s == "いいよ = logこいよ"

0 commit comments

Comments
 (0)