vimamsa 0.1.27 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/appimage.yml +17 -10
- data/Dockerfile +2 -2
- data/README.md +162 -90
- data/custom_example.rb +33 -15
- data/doc/TODO.md +334 -110
- data/doc/action_names_plan.md +442 -0
- data/doc/bundling_plan.md +2 -1
- data/doc/delta_syntax_plan.md +293 -0
- data/doc/demo_recording_plan.md +288 -0
- data/doc/design_goals.md +27 -0
- data/doc/intro_page_plan.md +266 -0
- data/doc/key_bindings_report_plan.md +45 -0
- data/doc/line_tree_plan.md +89 -0
- data/doc/missing_vim_bindings.md +34 -44
- data/doc/modules_settings_plan.md +1 -1
- data/doc/registries_plan.md +202 -0
- data/doc/startup_speed_plan.md +97 -0
- data/doc/test_commands.md +232 -0
- data/doc/treap_visualizer.html +585 -0
- data/doc/vim_compatibility_plan.md +186 -31
- data/doc/vimlike_vim_conflicts.md +236 -228
- data/doc/vm_snapshots_plan.md +4 -4
- data/doc/wysiwyg_plan.md +231 -0
- data/docker_cmd.sh +1 -1
- data/exe/run_tests.rb +85 -3
- data/exe/vimamsa +49 -6
- data/help/intro.txt +30 -0
- data/help/vim_intro.txt +31 -0
- data/img/demo.gif +0 -0
- data/img/demo.mp4 +0 -0
- data/lang/hyperplaintext.lang +1 -1
- data/lib/vimamsa/ack.rb +2 -0
- data/lib/vimamsa/actions.rb +381 -36
- data/lib/vimamsa/bookmarks.rb +8 -8
- data/lib/vimamsa/buffer.rb +84 -38
- data/lib/vimamsa/buffer_changetext.rb +58 -36
- data/lib/vimamsa/buffer_list.rb +2 -2
- data/lib/vimamsa/buffer_manager.rb +6 -6
- data/lib/vimamsa/cli_help.rb +75 -0
- data/lib/vimamsa/clipboard.rb +6 -3
- data/lib/vimamsa/conf.rb +9 -0
- data/lib/vimamsa/crash_handler.rb +2 -2
- data/lib/vimamsa/debug.rb +2 -2
- data/lib/vimamsa/demo_player.rb +494 -0
- data/lib/vimamsa/demo_recorder.rb +277 -0
- data/lib/vimamsa/diff_buffer.rb +1 -1
- data/lib/vimamsa/dot_repeat.rb +104 -0
- data/lib/vimamsa/easy_jump.rb +54 -3
- data/lib/vimamsa/editor.rb +136 -65
- data/lib/vimamsa/file_history.rb +1 -1
- data/lib/vimamsa/file_manager.rb +23 -23
- data/lib/vimamsa/form_input.rb +388 -0
- data/lib/vimamsa/gui.rb +89 -13
- data/lib/vimamsa/gui_command_line.rb +44 -5
- data/lib/vimamsa/gui_form_generator.rb +17 -6
- data/lib/vimamsa/gui_func_panel.rb +1 -1
- data/lib/vimamsa/gui_key_hint.rb +165 -0
- data/lib/vimamsa/gui_keylog_panel.rb +164 -2
- data/lib/vimamsa/gui_menu.rb +69 -50
- data/lib/vimamsa/gui_select_window.rb +77 -43
- data/lib/vimamsa/gui_settings.rb +9 -5
- data/lib/vimamsa/gui_sourceview.rb +28 -81
- data/lib/vimamsa/gui_theme.rb +11 -2
- data/lib/vimamsa/hook.rb +2 -0
- data/lib/vimamsa/intro_page.rb +367 -0
- data/lib/vimamsa/key_actions.rb +315 -225
- data/lib/vimamsa/key_binding_tree.rb +228 -61
- data/lib/vimamsa/key_bindings_notepad.rb +18 -16
- data/lib/vimamsa/key_bindings_report.rb +290 -67
- data/lib/vimamsa/key_bindings_vim.rb +43 -297
- data/lib/vimamsa/key_bindings_vim_core.rb +356 -0
- data/lib/vimamsa/key_bindings_vimlike.rb +347 -339
- data/lib/vimamsa/key_names.rb +80 -0
- data/lib/vimamsa/langservp.rb +62 -7
- data/lib/vimamsa/line_tree.rb +367 -0
- data/lib/vimamsa/macro.rb +20 -3
- data/lib/vimamsa/rbvma.rb +15 -0
- data/lib/vimamsa/registers.rb +125 -0
- data/lib/vimamsa/run_ruby.rb +64 -0
- data/lib/vimamsa/search_replace.rb +4 -4
- data/lib/vimamsa/string_util.rb +17 -3
- data/lib/vimamsa/tests.rb +8 -8
- data/lib/vimamsa/text_objects.rb +11 -54
- data/lib/vimamsa/text_transforms.rb +4 -0
- data/lib/vimamsa/tmp_user_dir.rb +39 -0
- data/lib/vimamsa/user_dirs.rb +83 -0
- data/lib/vimamsa/version.rb +1 -1
- data/lib/vimamsa/vim_operators.rb +365 -0
- data/modules/calculator/calculator.rb +5 -5
- data/modules/color_highlight/color_highlight.rb +3 -3
- data/modules/dictation/dictation.rb +32 -32
- data/modules/ollama/ollama.rb +5 -5
- data/modules/terminal/terminal.rb +5 -5
- data/modules/tts/tts.rb +10 -10
- data/run_e2e_vm.sh +3 -3
- data/run_tests_vm.rb +163 -0
- data/scripts/appimage/AppRun +7 -0
- data/scripts/appimage/build_in_container.sh +11 -1
- data/scripts/appimage/smoke_test.sh +1 -1
- data/scripts/demo/demo_easyjump_steps.txt +60 -0
- data/scripts/demo/demo_files_steps.txt +52 -0
- data/scripts/demo/demo_steps.txt +9 -1
- data/scripts/demo/notes.txt +6 -0
- data/scripts/demo/record_demo.rb +60 -81
- data/scripts/demo/report.rb +7 -0
- data/scripts/demo/shapes.rb +1 -0
- data/scripts/demo/square/shapes.rb +29 -0
- data/scripts/demo/square/steps.txt +185 -0
- data/scripts/lib/perf_startup.rb +138 -0
- data/scripts/lib/script_helpers.rb +53 -0
- data/scripts/perf_compare.rb +34 -0
- data/scripts/profile_startup.rb +72 -0
- data/tests/test_action_ids.rb +232 -0
- data/tests/test_auto_format.rb +2 -2
- data/tests/test_autocomplete.rb +1 -1
- data/tests/test_basic_editing.rb +18 -18
- data/tests/test_bookmarks.rb +6 -6
- data/tests/test_bracket_match.rb +3 -0
- data/tests/test_cli_help.rb +64 -0
- data/tests/test_color_highlight.rb +2 -2
- data/tests/test_command_line.rb +1 -1
- data/tests/test_context_menu_file.rb +18 -0
- data/tests/test_copy_paste.rb +33 -33
- data/tests/test_custom_two_phase.rb +1 -1
- data/tests/test_demo_player.rb +355 -0
- data/tests/test_demo_recorder.rb +202 -0
- data/tests/test_dictation.rb +16 -16
- data/tests/test_dot_repeat.rb +88 -0
- data/tests/test_easy_jump.rb +93 -0
- data/tests/test_extract_file_links.rb +3 -3
- data/tests/test_file_panel.rb +2 -2
- data/tests/test_flash.rb +1 -1
- data/tests/test_fold.rb +1 -1
- data/tests/test_form_input.rb +203 -0
- data/tests/test_func_panel.rb +2 -2
- data/tests/test_gtk_sync.rb +7 -7
- data/tests/test_intro_page.rb +437 -0
- data/tests/test_key_categories.rb +163 -0
- data/tests/test_keylog_panel.rb +163 -3
- data/tests/test_line_ends.rb +51 -0
- data/tests/test_line_tree.rb +86 -0
- data/tests/test_lsp_clangd.rb +2 -2
- data/tests/test_lsp_root.rb +43 -0
- data/tests/test_macro.rb +2 -2
- data/tests/test_module_interface.rb +9 -9
- data/tests/test_notepad_bindings.rb +5 -5
- data/tests/test_perf_startup.rb +28 -0
- data/tests/test_random_edit.rb +27 -27
- data/tests/test_registers.rb +131 -0
- data/tests/test_run_ruby.rb +77 -0
- data/tests/test_startup_file.rb +45 -4
- data/tests/test_text_objects.rb +1 -1
- data/tests/test_text_transforms.rb +12 -0
- data/tests/test_tmp_user_dir.rb +79 -0
- data/tests/test_tts.rb +10 -10
- data/tests/test_undo.rb +34 -34
- data/tests/test_user_dirs.rb +122 -0
- data/tests/test_vim_bindings.rb +107 -6
- data/tests/test_vim_conflicts.rb +41 -4
- data/tests/test_vim_operators.rb +116 -0
- data/tests/test_window_layout.rb +83 -0
- data/vimamsa.gemspec +1 -1
- data/vm_guest_run.sh +75 -28
- metadata +60 -4
- data/run_tests.rb +0 -89
- data/run_tests_vm.sh +0 -130
|
@@ -30,7 +30,7 @@ class TestCustomTwoPhase < VmaTest
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def test_phase1_settings_reached_module_init
|
|
33
|
-
assert_eq ["fexp d d"], paths_of(
|
|
33
|
+
assert_eq ["fexp d d"], paths_of("fexp.cut_file"),
|
|
34
34
|
"cnf.fexp.experimental from the body of custom.rb should reach FileManager.init"
|
|
35
35
|
end
|
|
36
36
|
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
# Help ▸ Play demo: the README demo steps played inside the editor
|
|
2
|
+
# (demo_player.rb, scripts/demo/demo_steps.txt)
|
|
3
|
+
class TestDemoPlayer < VmaTest
|
|
4
|
+
SHAPES = File.join(DemoPlayer::DIR, "shapes.rb")
|
|
5
|
+
|
|
6
|
+
def wait_until_done(player, secs = 60)
|
|
7
|
+
wait_for(secs) { !player.running? }
|
|
8
|
+
assert !player.running?, "demo still running after #{secs} s"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Runs the main loop until the block is true or secs pass; the block's value
|
|
12
|
+
def wait_for(secs)
|
|
13
|
+
t = Time.now
|
|
14
|
+
until (ok = yield) || Time.now - t > secs
|
|
15
|
+
drain_idle
|
|
16
|
+
sleep 0.005
|
|
17
|
+
end
|
|
18
|
+
ok
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Runs the main loop for secs
|
|
22
|
+
def idle_for(secs)
|
|
23
|
+
wait_for(secs) { false }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# A short demo: after a wait, x deletes the first character of the file;
|
|
27
|
+
# then the closing wait, if any
|
|
28
|
+
def short_player(wait, closing = nil, **opts)
|
|
29
|
+
steps = [["wait", wait.to_s], ["keys", "x"]]
|
|
30
|
+
steps << ["wait", closing.to_s] if closing
|
|
31
|
+
# on the easy jump demo's file (scripts/demo/shapes.rb, as original)
|
|
32
|
+
DemoPlayer.new(:easyjump, speed: 1, steps: steps, **opts)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def original
|
|
36
|
+
File.read(SHAPES)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_steps_parse
|
|
40
|
+
steps = DemoPlayer.parse(File.read(DemoPlayer::STEPS))
|
|
41
|
+
assert steps.any? { |c, a| c == "keys" && a.include?("@JUMP_LABEL@") }
|
|
42
|
+
assert steps.any? { |c, _| c == "target" }, "no target line for the easy jump"
|
|
43
|
+
assert steps.any? { |c, a| c == "type" && a.start_with?("puts ") }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# The basic demo (square/steps.txt), fast: it plays to the end and turns
|
|
47
|
+
# Circle into a Square class with a width (search and replace in a form,
|
|
48
|
+
# the action search, easy jumps), back in Command mode
|
|
49
|
+
# (Not faster: at 50x an easy jump can come before the view has scrolled
|
|
50
|
+
# to its target, which then has no label.)
|
|
51
|
+
def test_plays_whole_demo
|
|
52
|
+
# its action searches find the same action whatever else is registered
|
|
53
|
+
assert_eq "sel.convert.remove_empty_lines", vma.actions.search_actions_update_callback("sel.convert.remempty")[0][1]
|
|
54
|
+
assert_eq "sel.convert.eval", vma.actions.search_actions_update_callback("sel.convert.eval")[0][1]
|
|
55
|
+
p = DemoPlayer.new(speed: 3, loop: false)
|
|
56
|
+
p.start
|
|
57
|
+
wait_until_done(p, 300)
|
|
58
|
+
assert_eq "Demo finished", p.stop_message
|
|
59
|
+
t = p.buf.to_s
|
|
60
|
+
assert t.include?("class Square < Shape"), t
|
|
61
|
+
assert t.include?("@width**2"), t
|
|
62
|
+
# the action search ran the eval converter on the whole file
|
|
63
|
+
assert t.end_with?("[3.141592653589793, 1]\n\n") || t.include?("[3.141592653589793, 1]"), t
|
|
64
|
+
assert_mode :command
|
|
65
|
+
ensure
|
|
66
|
+
vma.buffers.close_buffer(p.buf.id) if p&.buf
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# The easy jump demo moves Shape#to_s above area, with v + easy jump to
|
|
70
|
+
# select it, x and P
|
|
71
|
+
def test_easyjump_demo_moves_to_s
|
|
72
|
+
p = DemoPlayer.new(:easyjump, speed: 50, loop: false)
|
|
73
|
+
p.start
|
|
74
|
+
wait_until_done(p)
|
|
75
|
+
l = original.lines
|
|
76
|
+
want = l[0..4] + ["\n"] + l[10..12] + ["\n"] + l[6..8] + l[13..]
|
|
77
|
+
assert_eq want.join, p.buf.to_s
|
|
78
|
+
assert_mode :command
|
|
79
|
+
ensure
|
|
80
|
+
vma.buffers.close_buffer(p.buf.id) if p&.buf
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# The file switching demo: tab, browse mode h / l and the file explorer
|
|
84
|
+
# visit every file and end on shapes.rb, unchanged, at the top
|
|
85
|
+
def test_files_demo_switches_files
|
|
86
|
+
p = DemoPlayer.new(:files, speed: 20, loop: false)
|
|
87
|
+
p.start
|
|
88
|
+
seen = []
|
|
89
|
+
t = Time.now
|
|
90
|
+
while p.running? && Time.now - t < 60
|
|
91
|
+
seen << File.basename(vma.buf.fname.to_s)
|
|
92
|
+
drain_idle
|
|
93
|
+
sleep 0.005
|
|
94
|
+
end
|
|
95
|
+
assert !p.running?, "demo still running"
|
|
96
|
+
order = seen.chunk_while { |a, b| a == b }.map(&:first)
|
|
97
|
+
assert_eq "Demo finished", p.stop_message, "#{p.stop_message}; buffers in order: #{order.inspect}, log: #{vma.gui.keylog_panel.entries.last(4).map { |e| e[:chord] || e[:text] }.inspect}"
|
|
98
|
+
# "": the file explorer's buffer
|
|
99
|
+
assert_eq ["", "notes.txt", "report.rb", "shapes.rb"], seen.uniq.sort
|
|
100
|
+
assert_eq "shapes.rb", File.basename(vma.buf.fname.to_s)
|
|
101
|
+
assert_eq File.read(SHAPES), vma.buf.to_s
|
|
102
|
+
assert_eq 0, vma.buf.pos
|
|
103
|
+
assert vma.buffers.list.none? { |b| b.module.is_a?(FileManager) rescue false }, "file explorer still open"
|
|
104
|
+
ensure
|
|
105
|
+
p&.bufs&.each { |b| vma.buffers.close_buffer(b.id) }
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def test_easyjump_steps_parse
|
|
109
|
+
steps = DemoPlayer.parse(File.read(DemoPlayer::DEMOS[:easyjump][:steps]))
|
|
110
|
+
assert steps.count { |c, a| c == "keys" && a.include?("@JUMP_LABEL@") } >= 5
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Another demo from the menu stops the playing one and starts; the same
|
|
114
|
+
# one again stops it
|
|
115
|
+
def test_toggle_switches_demo
|
|
116
|
+
DemoPlayer.toggle(:basic)
|
|
117
|
+
a = DemoPlayer.current
|
|
118
|
+
DemoPlayer.toggle(:easyjump)
|
|
119
|
+
b = DemoPlayer.current
|
|
120
|
+
assert !a.running?
|
|
121
|
+
assert b.running?
|
|
122
|
+
assert_eq :easyjump, b.name
|
|
123
|
+
DemoPlayer.toggle(:easyjump)
|
|
124
|
+
assert !b.running?
|
|
125
|
+
drain_idle
|
|
126
|
+
ensure
|
|
127
|
+
[a, b].compact.each { |x| x.stop; vma.buffers.close_buffer(x.buf.id) if x.buf }
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# The key log's close button stops the demo and hides the panel
|
|
131
|
+
def test_close_button_stops_demo
|
|
132
|
+
p = short_player(5)
|
|
133
|
+
p.start
|
|
134
|
+
panel = vma.gui.keylog_panel
|
|
135
|
+
assert panel.active?, "key log not shown by the demo"
|
|
136
|
+
panel.close_btn.signal_emit("clicked")
|
|
137
|
+
drain_idle
|
|
138
|
+
assert !p.running?, "demo still running"
|
|
139
|
+
assert !panel.active?, "key log still shown"
|
|
140
|
+
ensure
|
|
141
|
+
p&.stop
|
|
142
|
+
vma.buffers.close_buffer(p.buf.id) if p&.buf
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# The easy jump label is looked up for the target line in this window (a
|
|
146
|
+
# line near the top: the test window may not show line 16 the demo uses)
|
|
147
|
+
def test_jump_label_reaches_target
|
|
148
|
+
p = DemoPlayer.new
|
|
149
|
+
b = create_new_buffer(File.read(SHAPES), "demotest", true)
|
|
150
|
+
p.instance_variable_set(:@buf, b)
|
|
151
|
+
p.instance_variable_set(:@target, " def area")
|
|
152
|
+
b.set_pos(0)
|
|
153
|
+
# Let the new view get laid out: easy jump labels only what's visible
|
|
154
|
+
20.times { drain_idle; sleep 0.02 }
|
|
155
|
+
keys("s")
|
|
156
|
+
ej = EasyJump.class_variable_get(:@@cur)
|
|
157
|
+
label = p.send(:jump_label)
|
|
158
|
+
marks = ej.instance_variable_get(:@easy_jump_wsmarks)
|
|
159
|
+
assert label != ["esc"], "no label: target line start #{b.index(" def area")}, marks #{marks.first(30).inspect}, visible #{get_visible_area.inspect}, cur buf #{vma.buf.equal?(b)}"
|
|
160
|
+
label.each { |c| p.send(:press, c) }
|
|
161
|
+
assert_eq b.index(" def area"), b.pos
|
|
162
|
+
ensure
|
|
163
|
+
vma.buffers.close_buffer(b.id) if b
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# At the end the file goes back to how it was and the demo plays again
|
|
167
|
+
def test_loops_until_stopped
|
|
168
|
+
p = short_player(0.3, 0.3)
|
|
169
|
+
p.start
|
|
170
|
+
assert wait_for(5) { p.buf.to_s == original[1..] }, "the first round didn't delete a char"
|
|
171
|
+
assert wait_for(5) { p.rounds >= 1 }, "no second round"
|
|
172
|
+
assert p.running?
|
|
173
|
+
assert_eq original, p.buf.to_s
|
|
174
|
+
assert wait_for(5) { p.buf.to_s == original[1..] }, "the second round didn't play"
|
|
175
|
+
p.stop
|
|
176
|
+
assert !p.running?
|
|
177
|
+
ensure
|
|
178
|
+
p&.stop
|
|
179
|
+
vma.buffers.close_buffer(p.buf.id) if p&.buf
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# The key log starts empty, without the keys typed before the demo
|
|
183
|
+
def test_key_log_cleared_at_start
|
|
184
|
+
act "panel.keylog.toggle"
|
|
185
|
+
keys "j k"
|
|
186
|
+
assert vma.gui.keylog_panel.entries.size > 0
|
|
187
|
+
p = short_player(5, loop: false)
|
|
188
|
+
p.start
|
|
189
|
+
assert_eq [], vma.gui.keylog_panel.entries
|
|
190
|
+
ensure
|
|
191
|
+
p&.stop
|
|
192
|
+
vma.buffers.close_buffer(p.buf.id) if p&.buf
|
|
193
|
+
act "panel.keylog.toggle" if vma.gui.keylog_panel.active?
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# Paused, the step waits; continued, it runs. The button label follows.
|
|
197
|
+
def test_pause_and_continue
|
|
198
|
+
p = short_player(0.2, loop: false)
|
|
199
|
+
panel = vma.gui.keylog_panel
|
|
200
|
+
p.start
|
|
201
|
+
assert panel.demo_bar.visible?
|
|
202
|
+
assert_eq "Pause", panel.demo_pause_btn.label
|
|
203
|
+
p.toggle_pause
|
|
204
|
+
assert p.paused?
|
|
205
|
+
assert_eq "Continue", panel.demo_pause_btn.label
|
|
206
|
+
idle_for(0.6)
|
|
207
|
+
assert_eq original, p.buf.to_s, "a paused demo went on"
|
|
208
|
+
p.toggle_pause
|
|
209
|
+
assert !p.paused?
|
|
210
|
+
assert_eq "Pause", panel.demo_pause_btn.label
|
|
211
|
+
wait_until_done(p, 5)
|
|
212
|
+
assert_eq original[1..], p.buf.to_s
|
|
213
|
+
assert !panel.demo_bar.visible?, "demo controls still shown after the end"
|
|
214
|
+
ensure
|
|
215
|
+
p&.stop
|
|
216
|
+
vma.buffers.close_buffer(p.buf.id) if p&.buf
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# While it plays, the GUI ignores the user's keys and clicks; paused or
|
|
220
|
+
# stopped, it doesn't
|
|
221
|
+
def test_blocks_input_while_playing
|
|
222
|
+
p = short_player(5, loop: false)
|
|
223
|
+
assert !DemoPlayer.blocks_input?
|
|
224
|
+
p.start
|
|
225
|
+
assert DemoPlayer.blocks_input?, "a playing demo lets user input through"
|
|
226
|
+
p.toggle_pause
|
|
227
|
+
assert !DemoPlayer.blocks_input?, "a paused demo blocks user input"
|
|
228
|
+
p.toggle_pause
|
|
229
|
+
assert DemoPlayer.blocks_input?
|
|
230
|
+
p.stop
|
|
231
|
+
assert !DemoPlayer.blocks_input?, "a stopped demo blocks user input"
|
|
232
|
+
ensure
|
|
233
|
+
p&.stop
|
|
234
|
+
vma.buffers.close_buffer(p.buf.id) if p&.buf
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Edited while paused: continuing starts the demo from the beginning, on
|
|
238
|
+
# the file as it was at the start
|
|
239
|
+
def test_edit_while_paused_restarts
|
|
240
|
+
p = short_player(0.2, loop: false)
|
|
241
|
+
p.start
|
|
242
|
+
p.toggle_pause
|
|
243
|
+
keys "i h e l l o esc"
|
|
244
|
+
assert p.buf.to_s.start_with?("hello"), p.buf.to_s[0, 20]
|
|
245
|
+
p.toggle_pause
|
|
246
|
+
assert_eq original, p.buf.to_s
|
|
247
|
+
assert_eq 0, p.buf.pos
|
|
248
|
+
assert_eq 0, p.rounds
|
|
249
|
+
wait_until_done(p, 5)
|
|
250
|
+
assert_eq "Demo finished", p.stop_message
|
|
251
|
+
assert_eq original[1..], p.buf.to_s
|
|
252
|
+
ensure
|
|
253
|
+
p&.stop
|
|
254
|
+
vma.buffers.close_buffer(p.buf.id) if p&.buf
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
# Only the cursor moved while paused: that too starts it again
|
|
258
|
+
def test_cursor_move_while_paused_restarts
|
|
259
|
+
p = short_player(0.2, loop: false)
|
|
260
|
+
p.start
|
|
261
|
+
p.toggle_pause
|
|
262
|
+
keys "j j l"
|
|
263
|
+
assert p.buf.pos > 0
|
|
264
|
+
p.toggle_pause
|
|
265
|
+
assert_eq 0, p.buf.pos
|
|
266
|
+
wait_until_done(p, 5)
|
|
267
|
+
assert_eq original[1..], p.buf.to_s
|
|
268
|
+
ensure
|
|
269
|
+
p&.stop
|
|
270
|
+
vma.buffers.close_buffer(p.buf.id) if p&.buf
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
# A demo from any steps file (scripts/demo/record_demo.rb): no controls,
|
|
274
|
+
# on_finish gets the stop message
|
|
275
|
+
def test_given_demo_without_controls
|
|
276
|
+
got = nil
|
|
277
|
+
demo = { steps: DemoPlayer::DEMOS[:easyjump][:steps], files: ["shapes.rb"], src: DemoPlayer::DIR }
|
|
278
|
+
p = DemoPlayer.new(:recording, demo: demo, steps: [["wait", "0.1"], ["keys", "x"]], speed: 1, loop: false,
|
|
279
|
+
controls: false, on_finish: proc { |m| got = m })
|
|
280
|
+
p.start
|
|
281
|
+
assert !vma.gui.keylog_panel.demo_bar.visible?, "controls shown"
|
|
282
|
+
wait_until_done(p, 5)
|
|
283
|
+
assert_eq "Demo finished", got
|
|
284
|
+
assert_eq original[1..], p.buf.to_s
|
|
285
|
+
ensure
|
|
286
|
+
vma.buffers.close_buffer(p.buf.id) if p&.buf
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
# An easy jump target outside the window (a demo recorded in a bigger
|
|
290
|
+
# one): the cursor still ends on it
|
|
291
|
+
def test_jump_target_not_shown
|
|
292
|
+
Dir.mktmpdir("vma-demo-src") { |src|
|
|
293
|
+
File.write(File.join(src, "long.txt"), (1..300).map { |i| "line #{i} some words here\n" }.join)
|
|
294
|
+
steps = [["wait", "0.1"], ["keys", "s"], ["target", "line 200 col 6"], ["keys", "@JUMP_LABEL@"], ["keys", "x"]]
|
|
295
|
+
p = DemoPlayer.new(:recording, demo: { steps: nil, files: ["long.txt"], src: src }, steps: steps,
|
|
296
|
+
speed: 1, loop: false, controls: false)
|
|
297
|
+
p.start
|
|
298
|
+
wait_until_done(p, 10)
|
|
299
|
+
assert_eq "Demo finished", p.stop_message
|
|
300
|
+
l = p.buf.lines[199]
|
|
301
|
+
assert_eq "line 00 some words here\n", l, "x not at line 200 col 6"
|
|
302
|
+
assert_mode :command
|
|
303
|
+
}
|
|
304
|
+
ensure
|
|
305
|
+
vma.buffers.close_buffer(p.buf.id) if p&.buf
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
def test_speed_steps
|
|
309
|
+
p = DemoPlayer.new
|
|
310
|
+
r = p.rate
|
|
311
|
+
assert DemoPlayer::RATES.include?(r), "default rate #{r} not in RATES"
|
|
312
|
+
p.faster
|
|
313
|
+
assert_eq DemoPlayer::RATES[DemoPlayer::RATES.index(r) + 1], p.rate
|
|
314
|
+
8.times { p.faster }
|
|
315
|
+
assert_eq DemoPlayer::RATES.last, p.rate
|
|
316
|
+
20.times { p.slower }
|
|
317
|
+
assert_eq DemoPlayer::RATES.first, p.rate
|
|
318
|
+
assert_eq "0.25×", DemoPlayer.rate_label(0.25)
|
|
319
|
+
assert_eq "2×", DemoPlayer.rate_label(2)
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
# Speed divides the waits: a 2 s wait at 4× takes 0.5 s, a 0.2 s wait at
|
|
323
|
+
# 0.25× takes 0.8 s (the bounds are loose for slow machines)
|
|
324
|
+
def test_speed_changes_waits
|
|
325
|
+
p = short_player(2, loop: false)
|
|
326
|
+
p.set_rate(4)
|
|
327
|
+
p.start
|
|
328
|
+
assert_eq "4×", vma.gui.keylog_panel.demo_speed_lbl.label
|
|
329
|
+
assert wait_for(1.5) { !p.running? }, "a 2 s wait at 4× took over 1.5 s"
|
|
330
|
+
vma.buffers.close_buffer(p.buf.id)
|
|
331
|
+
|
|
332
|
+
p = short_player(0.2, loop: false)
|
|
333
|
+
p.set_rate(0.25)
|
|
334
|
+
p.start
|
|
335
|
+
idle_for(0.4)
|
|
336
|
+
assert p.running?, "a 0.2 s wait at 0.25× took under 0.4 s"
|
|
337
|
+
wait_until_done(p, 5)
|
|
338
|
+
ensure
|
|
339
|
+
p&.stop
|
|
340
|
+
vma.buffers.close_buffer(p.buf.id) if p&.buf
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
def test_toggle_stops
|
|
344
|
+
DemoPlayer.toggle
|
|
345
|
+
p = DemoPlayer.current
|
|
346
|
+
assert p.running?
|
|
347
|
+
assert vma.gui.keylog_panel.demo_bar.visible?
|
|
348
|
+
DemoPlayer.toggle
|
|
349
|
+
assert !p.running?
|
|
350
|
+
assert !vma.gui.keylog_panel.demo_bar.visible?
|
|
351
|
+
drain_idle
|
|
352
|
+
ensure
|
|
353
|
+
vma.buffers.close_buffer(p.buf.id) if p&.buf
|
|
354
|
+
end
|
|
355
|
+
end
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# Recording demos (demo_recorder.rb, doc/demo_recording_plan.md part 2):
|
|
2
|
+
# keys into steps, and a recorded demo played back (DemoPlayer user demos)
|
|
3
|
+
class TestDemoRecorder < VmaTest
|
|
4
|
+
K = DemoRecorder::Key
|
|
5
|
+
|
|
6
|
+
def lines(keys, end_line: 0)
|
|
7
|
+
DemoRecorder.steps(keys, end_line: end_line).lines.map(&:chomp).reject { |l| l.start_with?("#") }
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def wait_until(secs = 60)
|
|
11
|
+
t = Time.now
|
|
12
|
+
until yield || Time.now - t > secs
|
|
13
|
+
drain_idle
|
|
14
|
+
sleep 0.005
|
|
15
|
+
end
|
|
16
|
+
yield
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# delay from the typical gap, wait for a pause, type for Insert-mode typing
|
|
20
|
+
def test_steps_from_keys
|
|
21
|
+
ins = "a.edit.insert.char!('%s')"
|
|
22
|
+
keys = [
|
|
23
|
+
K.new(t: 0.0, key: "j", mode: :command, action: "move.line.next"),
|
|
24
|
+
K.new(t: 0.4, key: "j", mode: :command, action: "move.line.next"),
|
|
25
|
+
K.new(t: 3.0, key: "i", mode: :command, action: "mode.insert"),
|
|
26
|
+
K.new(t: 3.4, key: "h", mode: :insert, action: ins % "h"),
|
|
27
|
+
K.new(t: 3.8, key: "i", mode: :insert, action: ins % "i"),
|
|
28
|
+
K.new(t: 4.2, key: "esc", mode: :insert, action: "mode.prev"),
|
|
29
|
+
]
|
|
30
|
+
assert_eq ["delay 0.4", "wait 1", "keys j j", "wait 2.2", "keys i", "type hi", "keys esc"], lines(keys)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_long_pause_capped
|
|
34
|
+
keys = [K.new(t: 0.0, key: "j", mode: :command, action: "x"), K.new(t: 30.0, key: "k", mode: :command, action: "x")]
|
|
35
|
+
assert lines(keys).include?("wait 3"), lines(keys).inspect
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Leading spaces of typed text go in a keys line ("type " would lose them)
|
|
39
|
+
def test_typed_leading_space
|
|
40
|
+
keys = [" ", "a"].each_with_index.map { |c, i|
|
|
41
|
+
K.new(t: i * 0.3, key: c == " " ? "space" : c, mode: :insert, action: c == " " ? "edit.insert.space" : "a.edit.insert.char!('a')")
|
|
42
|
+
}
|
|
43
|
+
assert_eq ["keys space", "type a"], lines(keys).last(2)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# An easy jump's label keys become the target line and @JUMP_LABEL@
|
|
47
|
+
def test_easy_jump_label
|
|
48
|
+
keys = [
|
|
49
|
+
K.new(t: 0.0, key: "s", mode: :command, action: "jump.easy", line: 0),
|
|
50
|
+
K.new(t: 0.4, key: "a", mode: :command, action: nil, line: 0, read: true),
|
|
51
|
+
K.new(t: 0.8, key: "b", mode: :command, action: nil, line: 0, read: true),
|
|
52
|
+
K.new(t: 1.2, key: "d", mode: :command, action: nil, line: 7, col: 12),
|
|
53
|
+
K.new(t: 1.4, key: "d", mode: :command, action: "edit.delete.line", line: 7),
|
|
54
|
+
]
|
|
55
|
+
l = lines(keys)
|
|
56
|
+
i = l.index("keys s")
|
|
57
|
+
assert i, l.inspect
|
|
58
|
+
# the d of d d has no action, but isn't a label key
|
|
59
|
+
assert_eq ["target line 8 col 13", "keys @JUMP_LABEL@", "keys d d"], l[i + 1, 3]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# ctrl alone is a key ("ctrl!"), ctrl held for ctrl-r is not
|
|
63
|
+
def test_bare_modifier
|
|
64
|
+
r = DemoRecorder.new
|
|
65
|
+
r.instance_variable_set(:@recording, true)
|
|
66
|
+
r.instance_variable_set(:@t0, 0)
|
|
67
|
+
r.key_input("ctrl", :key_press)
|
|
68
|
+
r.key_input("ctrl!", :key_release)
|
|
69
|
+
r.key_input("ctrl", :key_press)
|
|
70
|
+
r.key_input("ctrl-r", :key_press)
|
|
71
|
+
r.key_input("j", :key_press)
|
|
72
|
+
r.key_input("j!", :key_release)
|
|
73
|
+
assert_eq ["ctrl", "ctrl-r", "j"], r.keys.map(&:key)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Record real keys (an edit and , r r with typing in the form), name it in
|
|
77
|
+
# the save form, play it back: the same text
|
|
78
|
+
def test_record_save_and_play_back
|
|
79
|
+
b = create_new_buffer("one two one\nline two\n", "rectest")
|
|
80
|
+
rec = DemoRecorder.new
|
|
81
|
+
DemoRecorder.current = rec
|
|
82
|
+
rec.start
|
|
83
|
+
keys "j d d"
|
|
84
|
+
keys ", r r o n e tab 1 enter"
|
|
85
|
+
want = b.to_s.dup
|
|
86
|
+
assert_eq "1 two 1\n", want
|
|
87
|
+
rec.stop
|
|
88
|
+
assert FormInput.current, "no name form"
|
|
89
|
+
keys "ctrl-a r t enter"
|
|
90
|
+
dir = File.join(DemoPlayer.user_demos_dir, "rt")
|
|
91
|
+
assert File.exist?(File.join(dir, "steps.txt")), "not saved"
|
|
92
|
+
steps = File.read(File.join(dir, "steps.txt"))
|
|
93
|
+
assert steps.include?("type one"), steps
|
|
94
|
+
assert_eq "one two one\nline two\n", File.read(File.join(dir, "demo.txt")), "start file"
|
|
95
|
+
assert_eq :user_rt, DemoRecorder.last_saved
|
|
96
|
+
assert DemoPlayer.demos.key?(:user_rt)
|
|
97
|
+
assert vma.actions.include?("help.demo.user.rt")
|
|
98
|
+
|
|
99
|
+
p = DemoPlayer.new(:user_rt, speed: 50, loop: false)
|
|
100
|
+
p.start
|
|
101
|
+
assert wait_until { !p.running? }, "demo still running"
|
|
102
|
+
assert_eq "Demo finished", p.stop_message, steps
|
|
103
|
+
assert_eq want, p.buf.to_s, steps
|
|
104
|
+
ensure
|
|
105
|
+
DemoRecorder.current = nil
|
|
106
|
+
FormInput.current&.cancel
|
|
107
|
+
drain_idle
|
|
108
|
+
p&.bufs&.each { |x| vma.buffers.close_buffer(x.id) }
|
|
109
|
+
FileUtils.rm_rf(DemoPlayer.user_demos_dir)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# An easy jump to a word inside a line (s + a label), then d w: all keys
|
|
113
|
+
# play back, at the same character (the d, which has no action, used to be
|
|
114
|
+
# taken for a label key)
|
|
115
|
+
def test_record_dd_then_easy_jump
|
|
116
|
+
text = (1..12).map { |i| "line number #{i} with words\n" }.join
|
|
117
|
+
b = create_new_buffer(text, "rectest")
|
|
118
|
+
# easy jump labels only what is shown: wait until the view is laid out
|
|
119
|
+
assert wait_until(10) { (a = get_visible_area) && a[1] - a[0] > 100 }, "view not laid out: #{get_visible_area.inspect}"
|
|
120
|
+
rec = DemoRecorder.new
|
|
121
|
+
DemoRecorder.current = rec
|
|
122
|
+
rec.start
|
|
123
|
+
keys "s"
|
|
124
|
+
ej = EasyJump.class_variable_get(:@@cur)
|
|
125
|
+
# a labelled word inside line 6, not its start
|
|
126
|
+
ls = b.index("line number 6")
|
|
127
|
+
marks = ej.instance_variable_get(:@easy_jump_wsmarks)
|
|
128
|
+
target = marks.select { |m| m > ls && m < b.index("\n", ls) }.min
|
|
129
|
+
assert target, "no labelled word inside line 6: #{marks.sort.inspect}"
|
|
130
|
+
n = marks.index(target)
|
|
131
|
+
label = ej.instance_variable_get(:@jump_sequence)[n].downcase.chars
|
|
132
|
+
keys label.join(" ")
|
|
133
|
+
assert_eq target, b.pos, "jump"
|
|
134
|
+
keys "d w"
|
|
135
|
+
keys "x"
|
|
136
|
+
want = b.to_s.dup
|
|
137
|
+
rec.stop(save: false)
|
|
138
|
+
steps = rec.steps_text(file: "demo.txt")
|
|
139
|
+
assert steps.include?("keys d w"), steps
|
|
140
|
+
col = target - ls + 1
|
|
141
|
+
assert steps.include?("target line 6 col #{col}"), steps
|
|
142
|
+
rec.save("ddjump")
|
|
143
|
+
p = DemoPlayer.new(:user_ddjump, speed: 50, loop: false)
|
|
144
|
+
p.start
|
|
145
|
+
assert wait_until { !p.running? }, "demo still running"
|
|
146
|
+
assert_eq want, p.buf.to_s, steps
|
|
147
|
+
ensure
|
|
148
|
+
vma.kbd.remove_keyhandling_override # easy jump left reading keys
|
|
149
|
+
vma.gui.clear_overlay rescue nil
|
|
150
|
+
vma.kbd.set_mode(:command)
|
|
151
|
+
DemoRecorder.current = nil
|
|
152
|
+
p&.bufs&.each { |x| vma.buffers.close_buffer(x.id) }
|
|
153
|
+
FileUtils.rm_rf(DemoPlayer.user_demos_dir)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# The action search (a list window): select lines, , , s, type a fuzzy
|
|
157
|
+
# name, enter. It is recorded (form mode) and plays back.
|
|
158
|
+
def test_record_action_search
|
|
159
|
+
b = create_new_buffer("a\n\nb\n\nc\n", "rectest")
|
|
160
|
+
rec = DemoRecorder.new
|
|
161
|
+
DemoRecorder.current = rec
|
|
162
|
+
rec.start
|
|
163
|
+
keys "v j j j"
|
|
164
|
+
keys ", , s"
|
|
165
|
+
assert FormInput.current, "action search not in form mode"
|
|
166
|
+
keys "r e m e m p t y l i n e s"
|
|
167
|
+
keys "enter"
|
|
168
|
+
assert FormInput.current.nil?, "action search still open"
|
|
169
|
+
want = b.to_s.dup
|
|
170
|
+
assert_eq "a\nb\nc\n", want
|
|
171
|
+
rec.stop(save: false)
|
|
172
|
+
steps = rec.steps_text(file: "demo.txt")
|
|
173
|
+
assert steps.include?("type rememptylines"), steps
|
|
174
|
+
assert steps.include?("keys enter"), steps
|
|
175
|
+
rec.save("search")
|
|
176
|
+
p = DemoPlayer.new(:user_search, speed: 50, loop: false)
|
|
177
|
+
p.start
|
|
178
|
+
assert wait_until { !p.running? }, "demo still running"
|
|
179
|
+
assert_eq want, p.buf.to_s, steps
|
|
180
|
+
ensure
|
|
181
|
+
FormInput.current&.cancel
|
|
182
|
+
vma.kbd.set_mode(:command)
|
|
183
|
+
DemoRecorder.current = nil
|
|
184
|
+
p&.bufs&.each { |x| vma.buffers.close_buffer(x.id) }
|
|
185
|
+
FileUtils.rm_rf(DemoPlayer.user_demos_dir)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# The stop command's own keys aren't in the demo
|
|
189
|
+
def test_stop_keys_dropped
|
|
190
|
+
rec = DemoRecorder.new
|
|
191
|
+
DemoRecorder.current = rec
|
|
192
|
+
rec.start
|
|
193
|
+
keys "j"
|
|
194
|
+
rec.key_input(",", :key_press)
|
|
195
|
+
rec.key_input("x", :key_press)
|
|
196
|
+
rec.key_action("help.demo.record")
|
|
197
|
+
rec.stop(save: false)
|
|
198
|
+
assert_eq ["j"], rec.keys.map(&:key)
|
|
199
|
+
ensure
|
|
200
|
+
DemoRecorder.current = nil
|
|
201
|
+
end
|
|
202
|
+
end
|
data/tests/test_dictation.rb
CHANGED
|
@@ -5,7 +5,7 @@ class TestDictation < VmaTest
|
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
def ensure_disabled
|
|
8
|
-
dictation_disable if vma.actions.include?(
|
|
8
|
+
dictation_disable if vma.actions.include?("dictation.toggle")
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
# --- _info ---
|
|
@@ -23,8 +23,8 @@ class TestDictation < VmaTest
|
|
|
23
23
|
ensure_disabled
|
|
24
24
|
load_dictation
|
|
25
25
|
dictation_init
|
|
26
|
-
assert vma.actions.include?(
|
|
27
|
-
assert vma.gui.menu.module_action?(
|
|
26
|
+
assert vma.actions.include?("dictation.toggle"), "action not registered after init"
|
|
27
|
+
assert vma.gui.menu.module_action?("dictation.enter_mode"), "menu item missing after init"
|
|
28
28
|
ensure
|
|
29
29
|
dictation_disable
|
|
30
30
|
end
|
|
@@ -34,7 +34,7 @@ class TestDictation < VmaTest
|
|
|
34
34
|
ensure_disabled
|
|
35
35
|
load_dictation
|
|
36
36
|
dictation_init
|
|
37
|
-
hint = vma.gui.menu.kbd_hint(
|
|
37
|
+
hint = vma.gui.menu.kbd_hint("dictation.enter_mode")
|
|
38
38
|
assert hint.include?("[C]</span> , k"), "no , k hint: #{hint.inspect}"
|
|
39
39
|
ensure
|
|
40
40
|
dictation_disable
|
|
@@ -45,8 +45,8 @@ class TestDictation < VmaTest
|
|
|
45
45
|
load_dictation
|
|
46
46
|
dictation_init
|
|
47
47
|
dictation_disable
|
|
48
|
-
assert !vma.actions.include?(
|
|
49
|
-
assert !vma.gui.menu.module_action?(
|
|
48
|
+
assert !vma.actions.include?("dictation.toggle"), "action still registered after disable"
|
|
49
|
+
assert !vma.gui.menu.module_action?("dictation.enter_mode"), "menu item still present after disable"
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def test_init_disable_cycle
|
|
@@ -54,9 +54,9 @@ class TestDictation < VmaTest
|
|
|
54
54
|
load_dictation
|
|
55
55
|
3.times do |i|
|
|
56
56
|
dictation_init
|
|
57
|
-
assert vma.actions.include?(
|
|
57
|
+
assert vma.actions.include?("dictation.toggle"), "action missing after init (cycle #{i})"
|
|
58
58
|
dictation_disable
|
|
59
|
-
assert !vma.actions.include?(
|
|
59
|
+
assert !vma.actions.include?("dictation.toggle"), "action present after disable (cycle #{i})"
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -196,7 +196,7 @@ class TestDictation < VmaTest
|
|
|
196
196
|
elapsed = Time.now - t0
|
|
197
197
|
|
|
198
198
|
assert_eq false, res[:ok], "transcribe should fail when the model never loads"
|
|
199
|
-
assert res[:error].to_s.include?("
|
|
199
|
+
assert res[:error].to_s.include?("no progress"), "unexpected error: #{res[:error].inspect}"
|
|
200
200
|
assert elapsed < 10, "transcribe blocked #{elapsed.round(1)}s; should give up after the timeout"
|
|
201
201
|
ensure
|
|
202
202
|
cnf.dictation.startup_timeout = prev
|
|
@@ -232,18 +232,18 @@ class TestDictation < VmaTest
|
|
|
232
232
|
ensure_disabled
|
|
233
233
|
load_dictation
|
|
234
234
|
dictation_init
|
|
235
|
-
[
|
|
236
|
-
|
|
235
|
+
["dictation.enter_mode", "dictation.toggle_stay",
|
|
236
|
+
"dictation.newline", "dictation.exit_mode"].each do |a|
|
|
237
237
|
assert vma.actions.include?(a), "#{a} not registered after init"
|
|
238
238
|
end
|
|
239
239
|
dictation_disable
|
|
240
|
-
[
|
|
241
|
-
|
|
240
|
+
["dictation.enter_mode", "dictation.toggle_stay",
|
|
241
|
+
"dictation.newline", "dictation.exit_mode"].each do |a|
|
|
242
242
|
assert !vma.actions.include?(a), "#{a} still registered after disable"
|
|
243
243
|
end
|
|
244
244
|
end
|
|
245
245
|
|
|
246
|
-
# The menu item runs
|
|
246
|
+
# The menu item runs "dictation.enter_mode"; clicked while already in the
|
|
247
247
|
# mode it leaves the mode instead (session not active: no recorder starts).
|
|
248
248
|
def test_enter_mode_action_exits_when_in_mode
|
|
249
249
|
ensure_disabled
|
|
@@ -251,7 +251,7 @@ class TestDictation < VmaTest
|
|
|
251
251
|
dictation_init
|
|
252
252
|
vma.kbd.set_mode(:dictation)
|
|
253
253
|
assert_eq :dictation, vma.kbd.get_mode
|
|
254
|
-
act(
|
|
254
|
+
act("dictation.enter_mode")
|
|
255
255
|
assert_eq :command, vma.kbd.get_mode, "menu toggle did not leave dictation mode"
|
|
256
256
|
ensure
|
|
257
257
|
vma.kbd.set_mode(:command)
|
|
@@ -286,7 +286,7 @@ class TestDictation < VmaTest
|
|
|
286
286
|
act("buf.insert_txt_at('abc', 0)") # fresh buffer "\n" -> "abc\n"
|
|
287
287
|
act("buf.set_pos(3)") # end of "abc", before the trailing "\n"
|
|
288
288
|
assert !dictation_session.active?, "precondition: no active dictation"
|
|
289
|
-
act(
|
|
289
|
+
act("dictation.newline")
|
|
290
290
|
assert_buf "abc\n\n", "Enter should insert a newline when not dictating"
|
|
291
291
|
ensure
|
|
292
292
|
dictation_disable
|