From db1542af3d03d304738fa22c1c848c2f02c37156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=E1=BA=A1m=20B=C3=ACnh=20An?= <111893501+brianhuster@users.noreply.github.com> Date: Sat, 19 Jul 2025 22:31:37 +0700 Subject: [PATCH] fix(tutor): use legacy syntax for lesson 3.1 #34996 Problem: - Extmark breaks lesson 3.1 of vim-01-beginner.tutor because when users delete the line and put it elsewhere, the extmark doesn't move to the put location. - This doesn't mean the extmark implementation is bad though (note that thanks to extmark, for the first time, we can make lesson 2.6 really interactive), it's just that the tutor format has never been made for kinds of lessons like lesson 3.1, which is why all "expected" in that lesson are -1, which also means that lesson is not interactive in the first place. Also see lesson 2.1.3 in vim-02-beginner, where the mark is just used to mark the first line of the exercise, which also prove my point. Solution: - For a not-really-interactive lesson like lesson 3.1, just use legacy syntax. I borrow the old vimtutor's `--->` to mark the exercises of the lesson. - Less redundant interactive marks also make the json files smaller and more maintainable. --- runtime/syntax/tutor.lua | 3 +++ runtime/tutor/en/vim-01-beginner.tutor | 10 +++++----- runtime/tutor/en/vim-01-beginner.tutor.json | 4 ---- runtime/tutor/ja/vim-01-beginner.tutor | 10 +++++----- runtime/tutor/ja/vim-01-beginner.tutor.json | 4 ---- runtime/tutor/zh/vim-01-beginner.tutor | 10 +++++----- runtime/tutor/zh/vim-01-beginner.tutor.json | 4 ---- 7 files changed, 18 insertions(+), 27 deletions(-) create mode 100644 runtime/syntax/tutor.lua diff --git a/runtime/syntax/tutor.lua b/runtime/syntax/tutor.lua new file mode 100644 index 0000000000..803baa3c6e --- /dev/null +++ b/runtime/syntax/tutor.lua @@ -0,0 +1,3 @@ +vim.cmd [[ +syntax match tutorExpect /^--->.*$/ +]] diff --git a/runtime/tutor/en/vim-01-beginner.tutor b/runtime/tutor/en/vim-01-beginner.tutor index 5da3d68fb4..2853ff9ce6 100644 --- a/runtime/tutor/en/vim-01-beginner.tutor +++ b/runtime/tutor/en/vim-01-beginner.tutor @@ -368,7 +368,7 @@ Fiix the errors oon thhis line and reeplace them witth undo. ** Type `p`{normal} to put previously deleted text after the cursor. ** - 1. Move the cursor to the first ✓ line below. + 1. Move the cursor to the first `--->` line below. 2. Type `dd`{normal} to delete the line and store it in a Neovim register. @@ -378,10 +378,10 @@ Fiix the errors oon thhis line and reeplace them witth undo. 5. Repeat steps 2 through 4 to put all the lines in correct order. -d) Can you learn too? -b) Violets are blue, -c) Intelligence is learned, -a) Roses are red, +---> d) Can you learn too? +---> b) Violets are blue, +---> c) Intelligence is learned, +---> a) Roses are red, NOTE: You can also put the text before the cursor with `P`{normal} (capital P). diff --git a/runtime/tutor/en/vim-01-beginner.tutor.json b/runtime/tutor/en/vim-01-beginner.tutor.json index d6cf66c799..5ff817269e 100644 --- a/runtime/tutor/en/vim-01-beginner.tutor.json +++ b/runtime/tutor/en/vim-01-beginner.tutor.json @@ -19,10 +19,6 @@ "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, - "382": -1, - "383": -1, - "384": -1, "400": "When this line was typed in, someone pressed some wrong keys!", "401": "When this line was typed in, someone pressed some wrong keys!", "421": "This line has a few words that need changing using the change operator.", diff --git a/runtime/tutor/ja/vim-01-beginner.tutor b/runtime/tutor/ja/vim-01-beginner.tutor index 9939a15c22..fb1cd8d548 100644 --- a/runtime/tutor/ja/vim-01-beginner.tutor +++ b/runtime/tutor/ja/vim-01-beginner.tutor @@ -368,7 +368,7 @@ This is just a line with words you can move around in. ** 最後に削除された行をカーソルの後に貼り付ける(Put)には `p`{normal} をタイプします。 ** - 1. ✓ と示された以下の最初の行にカーソルを移動しましょう。 + 1. `--->` と示された以下の最初の行にカーソルを移動しましょう。 2. `dd`{normal} とタイプして行を削除し、Neovim のレジスタに格納しましょう。 @@ -378,10 +378,10 @@ This is just a line with words you can move around in. 5. 順番が正しくなる様にステップ 2 から 4 を繰り返しましょう。 -d) 貴方も学ぶことができるか? -b) 菫は青く -c) 知恵とは学ぶもの -a) 薔薇は赤く +---> d) 貴方も学ぶことができるか? +---> b) 菫は青く +---> c) 知恵とは学ぶもの +---> a) 薔薇は赤く NOTE: `P`{normal} (大文字 P)とタイプすることで、カーソルの前に貼り付ける事もできます。 diff --git a/runtime/tutor/ja/vim-01-beginner.tutor.json b/runtime/tutor/ja/vim-01-beginner.tutor.json index 25edb36038..a05016873d 100644 --- a/runtime/tutor/ja/vim-01-beginner.tutor.json +++ b/runtime/tutor/ja/vim-01-beginner.tutor.json @@ -19,10 +19,6 @@ "313": "6) 砂糖は甘く", "314": "7) そして貴方も", "335": "この行の間違いを修正し、後でそれらの修正を取り消します。", - "381": -1, - "382": -1, - "383": -1, - "384": -1, "400": "この行を入力した時に、その人は幾つか間違ったキーを押しました!", "401": "この行を入力した時に、その人は幾つか間違ったキーを押しました!", "421": "This line has a few words that need changing using the change operator.", diff --git a/runtime/tutor/zh/vim-01-beginner.tutor b/runtime/tutor/zh/vim-01-beginner.tutor index b20a18c35d..cb667b0b38 100644 --- a/runtime/tutor/zh/vim-01-beginner.tutor +++ b/runtime/tutor/zh/vim-01-beginner.tutor @@ -352,7 +352,7 @@ Fix the errors on this line and replace them with undo. ** 输入 `p`{normal} 可以将之前删除的文本粘贴到光标之后。 ** - 1. 将光标移动到下面第一个标有 ✓ 的行。 + 1. 将光标移动到下面第一个标有 `--->` 的行。 2. 输入 `dd`{normal} 来删除该行,并将其存入 Neovim 的一个寄存器中。 @@ -362,10 +362,10 @@ Fix the errors on this line and replace them with undo. 5. 重复第 2 到 4 步,将所有行按正确的顺序(abcd)排列。 -d) Can you learn too? -b) Violets are blue, -c) Intelligence is learned, -a) Roses are red, +---> d) Can you learn too? +---> b) Violets are blue, +---> c) Intelligence is learned, +---> a) Roses are red, NOTE: 你也可以用 `P`{normal}(大写 P)将文本粘贴到光标之前。 diff --git a/runtime/tutor/zh/vim-01-beginner.tutor.json b/runtime/tutor/zh/vim-01-beginner.tutor.json index 52676db4e8..85912b3f37 100644 --- a/runtime/tutor/zh/vim-01-beginner.tutor.json +++ b/runtime/tutor/zh/vim-01-beginner.tutor.json @@ -22,10 +22,6 @@ "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.", - "365": -1, - "366": -1, - "367": -1, - "368": -1, "384": "When this line was typed in, someone pressed some wrong keys!", "385": "When this line was typed in, someone pressed some wrong keys!", "405": "This line has a few words that need changing using the change operator.",