refactor(tutor): reimplement interactive marks as extmark in Lua

Problem:
From https://matrix.to/#/!cylwlNXSwagQmZSkzs:matrix.org/$Ofj-TFIsEMbp0O9OhE8xuZSNi-nhRLtZTOgs6JRLNrs?via=matrix.org&via=gitter.im&via=mozilla.org

In lesson 2.6, users are asked to remove the second, forth and fifth
lines with `dd` command, then they are asked to undo twice to make the
text go back to original state. But after that, the mark ✗ appears
again, which confuses the user because they think they do something
wrong. This is a limitation with the current implementation, which is
based on line number only.

Solution:
Reimplement interactive marks as extmarks in Lua. This also make the
feature less fragile, as users can remove, add some arbitrary lines
without breaking the interactive marks.

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
This commit is contained in:
brianhuster
2025-07-13 23:44:39 +07:00
parent 444a8b3ec6
commit 1255a8d88d
8 changed files with 254 additions and 63 deletions

View File

@@ -304,7 +304,7 @@ it would be easier to simply type two d's to delete a line.
3. Now move to the fourth line.
4. Type `2dd`{normal} to delete two lines, then press `u`{normal} twice to undo all three lines.
4. Type `2dd`{normal} to delete two lines.
1) Roses are red,
2) Mud is fun,

View File

@@ -12,11 +12,11 @@
"273": -1,
"292": "This line of words is cleaned up.",
"309": "1) Roses are red,",
"310": "3) Violets are blue,",
"311": "6) Sugar is sweet",
"312": "7) And so are you.",
"313": "7) And so are you.",
"314": "7) And so are you.",
"310": "",
"311": "3) Violets are blue,",
"312": "",
"313": "",
"314": "6) Sugar is sweet",
"315": "7) And so are you.",
"335": "Fix the errors on this line and replace them with undo.",
"381": -1,

View File

@@ -11,13 +11,13 @@
"233": "誰かがこの行の最後を2度タイプしました。",
"272": -1,
"291": "この行の単語は綺麗になった。",
"308": -1,
"309": -1,
"310": -1,
"311": -1,
"312": -1,
"313": -1,
"314": -1,
"308": "1) 薔薇は赤く",
"309": "",
"310": "3) 菫は青く",
"311": "",
"312": "",
"313": "6) 砂糖は甘く",
"314": "7) そして貴方も",
"335": "この行の間違いを修正し、後でそれらの修正を取り消します。",
"381": -1,
"382": -1,

View File

@@ -287,7 +287,7 @@ This ABC DE line FGHI JK LMN OP of words is Q RS TUV cleaned up.
3. 现在移动到第 4 行。
4. 输入 `2dd`{normal} 来删除两行,然后按两次 `u`{normal} 来恢复这三行
4. 输入 `2dd`{normal} 来删除两行。
1) Roses are red,
2) Mud is fun,

View File

@@ -14,11 +14,11 @@
"259": -1,
"276": "This line of words is cleaned up.",
"292": "1) Roses are red,",
"293": "3) Violets are blue,",
"294": "6) Sugar is sweet",
"295": "7) And so are you.",
"296": "7) And so are you.",
"297": "7) And so are you.",
"293": "",
"294": "3) Violets are blue,",
"295": "",
"296": "",
"297": "6) Sugar is sweet",
"298": "7) And so are you.",
"318": "Fix the errors on this line and replace them with undo.",
"319": "Fix the errors on this line and replace them with undo.",