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
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Vim registers (registers.rb, doc/vim_compatibility_plan.md step 4)
|
|
2
|
+
class TestRegisters < VmaTest
|
|
3
|
+
# Put synchronously from the editor's copy (as in test_copy_paste): the
|
|
4
|
+
# system clipboard is read asynchronously and may belong to another program
|
|
5
|
+
def sync_paste
|
|
6
|
+
vma.macro.instance_variable_set(:@running_macro, true)
|
|
7
|
+
yield
|
|
8
|
+
ensure
|
|
9
|
+
vma.macro.instance_variable_set(:@running_macro, false)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def setup_text(s, pos = 0)
|
|
13
|
+
buf.set_content(s)
|
|
14
|
+
buf.set_pos(pos)
|
|
15
|
+
vma.kbd.set_mode(:command)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_linewise_put_in_another_buffer
|
|
19
|
+
setup_text("one\ntwo\n")
|
|
20
|
+
keys("y y")
|
|
21
|
+
create_new_buffer("a\nb\n", "regtest", true)
|
|
22
|
+
buf.set_pos(0)
|
|
23
|
+
sync_paste { keys("p") }
|
|
24
|
+
assert_buf "a\none\nb\n"
|
|
25
|
+
vma.buffers.close_buffer(buf.id)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_named_register
|
|
29
|
+
setup_text("one\ntwo\n")
|
|
30
|
+
keys('" a y y j')
|
|
31
|
+
assert_eq ["one\n", true], vma.registers["a"].to_a
|
|
32
|
+
keys('" a p')
|
|
33
|
+
assert_buf "one\ntwo\none\n"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# vim's i_ctrl-r in the default keymap too (VIM_BINDINGS): Insert mode,
|
|
37
|
+
# ctrl-r and a register name insert that register's text
|
|
38
|
+
def test_insert_register_in_insert_mode
|
|
39
|
+
setup_text("foo bar\n")
|
|
40
|
+
keys('" a y w')
|
|
41
|
+
keys("A space ctrl-r a esc")
|
|
42
|
+
assert_buf("foo bar foo \n")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_append_to_named_register
|
|
46
|
+
setup_text("one two\nthree\n")
|
|
47
|
+
keys('" a y y')
|
|
48
|
+
keys('j " A y y')
|
|
49
|
+
assert_eq ["one two\nthree\n", true], vma.registers["a"].to_a
|
|
50
|
+
vma.registers.store("x", reg: "b")
|
|
51
|
+
vma.registers.store("y", reg: "B")
|
|
52
|
+
assert_eq ["xy", false], vma.registers["b"].to_a
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_numbered_and_small_delete
|
|
56
|
+
setup_text("1\n2\n3\nfoo bar\n")
|
|
57
|
+
keys("d d d d")
|
|
58
|
+
assert_eq "2\n", vma.registers["1"].text
|
|
59
|
+
assert_eq "1\n", vma.registers["2"].text
|
|
60
|
+
keys("j d w") # a delete within one line goes to "-, not "1
|
|
61
|
+
assert_eq "foo ", vma.registers["-"].text
|
|
62
|
+
assert_eq "2\n", vma.registers["1"].text
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_yank_register_survives_deletes
|
|
66
|
+
setup_text("keep\ngone\n")
|
|
67
|
+
keys("y y j d d")
|
|
68
|
+
assert_eq "keep\n", vma.registers["0"].text
|
|
69
|
+
assert_eq "gone\n", vma.registers['"'].text
|
|
70
|
+
keys('" 0 P')
|
|
71
|
+
assert_buf "keep\nkeep\n"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_black_hole
|
|
75
|
+
setup_text("keep\ngone\n")
|
|
76
|
+
keys("y y j")
|
|
77
|
+
keys('" _ d d')
|
|
78
|
+
assert_buf "keep\n"
|
|
79
|
+
assert_eq "keep\n", vma.registers['"'].text
|
|
80
|
+
assert_eq "keep\n", vma.clipboard.get
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# "x applies to the next command only; a count may come between
|
|
84
|
+
def test_pending_register_is_used_once
|
|
85
|
+
setup_text("a\nb\nc\n")
|
|
86
|
+
keys('" q j y y')
|
|
87
|
+
assert vma.registers["q"].nil?, "register used by a later command"
|
|
88
|
+
keys('" w 2 y y')
|
|
89
|
+
assert_eq "b\nc\n", vma.registers["w"].text
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# A case change replaces the text but isn't a delete
|
|
93
|
+
def test_case_change_keeps_clipboard
|
|
94
|
+
setup_text("abc def\n")
|
|
95
|
+
keys("y y g U w")
|
|
96
|
+
assert_buf "ABC def\n"
|
|
97
|
+
assert_eq "abc def\n", vma.registers['"'].text
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def test_put_empty_register
|
|
101
|
+
setup_text("abc\n")
|
|
102
|
+
keys('" z p')
|
|
103
|
+
assert_buf "abc\n"
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def test_insert_register
|
|
107
|
+
setup_text("abc\n")
|
|
108
|
+
vma.registers.store("XY", reg: "k")
|
|
109
|
+
keys("i")
|
|
110
|
+
act("a.edit.insert.register!('k')")
|
|
111
|
+
keys("esc")
|
|
112
|
+
assert_buf "XYabc\n"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def test_operator_and_text_object_registers
|
|
116
|
+
setup_text("foo bar\n")
|
|
117
|
+
keys('" e c w') # vimlike has no c: the shared operator layer
|
|
118
|
+
keys("esc")
|
|
119
|
+
assert_eq ["foo", false], vma.registers["e"].to_a
|
|
120
|
+
setup_text("(x y)\n", 1)
|
|
121
|
+
keys('" f d i (')
|
|
122
|
+
assert_eq "x y", vma.registers["f"].text
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def test_show_registers
|
|
126
|
+
vma.registers.store("hello\n", linewise: true, reg: "h")
|
|
127
|
+
show_registers
|
|
128
|
+
assert buf.to_s.include?("\"h l hello^J"), buf.to_s
|
|
129
|
+
vma.buffers.close_buffer(buf.id)
|
|
130
|
+
end
|
|
131
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# buf.run.ruby (run_ruby.rb): the file run with Ruby in a separate process,
|
|
2
|
+
# its output (stdout and stderr in order) in a buffer
|
|
3
|
+
require "tmpdir"
|
|
4
|
+
|
|
5
|
+
class TestRunRuby < VmaTest
|
|
6
|
+
def outputs
|
|
7
|
+
vma.buffers.list.select { |b| b.instance_variable_get(:@ruby_output_of) }
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Runs b and returns the output buffer
|
|
11
|
+
def run_and_wait(b)
|
|
12
|
+
before = outputs.map(&:id)
|
|
13
|
+
act "buf.run.ruby"
|
|
14
|
+
t = Time.now
|
|
15
|
+
o = nil
|
|
16
|
+
until (o = outputs.find { |x| !before.include?(x.id) }) || Time.now - t > 20
|
|
17
|
+
drain_idle
|
|
18
|
+
sleep 0.02
|
|
19
|
+
end
|
|
20
|
+
assert o, "no output buffer"
|
|
21
|
+
o
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_runs_file_and_shows_output
|
|
25
|
+
Dir.mktmpdir("vma-run") { |d|
|
|
26
|
+
f = File.join(d, "hello.rb")
|
|
27
|
+
File.write(f, "puts 1 + 1\n$stderr.puts 'to stderr'\nputs File.basename(__FILE__)\n")
|
|
28
|
+
b = open_new_file(f)
|
|
29
|
+
o = run_and_wait(b)
|
|
30
|
+
assert o.to_s.start_with?("# ruby #{f} (exit 0,"), o.to_s.lines.first
|
|
31
|
+
assert o.to_s.include?("2\nto stderr\nhello.rb\n"), o.to_s
|
|
32
|
+
assert vma.buf.equal?(o)
|
|
33
|
+
vma.buffers.close_buffer(o.id)
|
|
34
|
+
vma.buffers.close_buffer(b.id)
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Unsaved changes are saved first; a second run replaces the output
|
|
39
|
+
def test_saves_first_and_replaces_output
|
|
40
|
+
Dir.mktmpdir("vma-run") { |d|
|
|
41
|
+
f = File.join(d, "edit.rb")
|
|
42
|
+
File.write(f, "puts :old\n")
|
|
43
|
+
b = open_new_file(f)
|
|
44
|
+
o1 = run_and_wait(b)
|
|
45
|
+
vma.buffers.set_current_buffer_by_id(b.id)
|
|
46
|
+
b.set_pos(0)
|
|
47
|
+
keys "d d"
|
|
48
|
+
keys "i p u t s space : n e w esc"
|
|
49
|
+
o2 = run_and_wait(b)
|
|
50
|
+
assert_eq "puts :new\n", File.read(f), "not saved before running"
|
|
51
|
+
assert o2.to_s.include?("new\n"), o2.to_s
|
|
52
|
+
assert vma.buffers.list.none? { |x| x.equal?(o1) }, "old output buffer still open"
|
|
53
|
+
assert_eq 1, outputs.size
|
|
54
|
+
vma.buffers.close_buffer(o2.id)
|
|
55
|
+
vma.buffers.close_buffer(b.id)
|
|
56
|
+
}
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# An error: the exit status and the message with its file:line
|
|
60
|
+
def test_error_and_buffer_without_file
|
|
61
|
+
b = create_new_buffer("puts :before\nraise 'boom'\n", "runtest")
|
|
62
|
+
o = run_and_wait(b)
|
|
63
|
+
assert o.to_s.lines.first.include?("exit 1"), o.to_s.lines.first
|
|
64
|
+
assert o.to_s.include?("before\n"), o.to_s
|
|
65
|
+
assert o.to_s =~ /vimamsa-run.*\.rb:2:in .*boom/, o.to_s
|
|
66
|
+
vma.buffers.close_buffer(o.id)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# The action search lists id and description in columns of their own
|
|
70
|
+
def test_action_search_columns
|
|
71
|
+
rows = vma.actions.search_actions_update_callback("bufrunruby")
|
|
72
|
+
row = rows.find { |_k, id, _d| id == "buf.run.ruby" }
|
|
73
|
+
assert row, rows.first(3).inspect
|
|
74
|
+
assert_eq 3, row.size
|
|
75
|
+
assert row[2].start_with?("Run the file as Ruby"), row.inspect
|
|
76
|
+
end
|
|
77
|
+
end
|
data/tests/test_startup_file.rb
CHANGED
|
@@ -3,6 +3,17 @@ require "tmpdir"
|
|
|
3
3
|
# cnf.startup_file is the buffer shown on startup even when the previous
|
|
4
4
|
# session is restored (restoring would otherwise leave its last file current).
|
|
5
5
|
class TestStartupFile < VmaTest
|
|
6
|
+
# Runs the main loop until the block is true (a session restore opens its
|
|
7
|
+
# files one per main loop turn)
|
|
8
|
+
def wait_until(secs = 10)
|
|
9
|
+
t = Time.now
|
|
10
|
+
until yield || Time.now - t > secs
|
|
11
|
+
drain_idle
|
|
12
|
+
sleep 0.01
|
|
13
|
+
end
|
|
14
|
+
yield
|
|
15
|
+
end
|
|
16
|
+
|
|
6
17
|
def test_startup_file_stays_current_after_session_restore
|
|
7
18
|
Dir.mktmpdir do |dir|
|
|
8
19
|
startup = "#{dir}/startup.txt"
|
|
@@ -11,7 +22,7 @@ class TestStartupFile < VmaTest
|
|
|
11
22
|
File.write(startup, "startup\n")
|
|
12
23
|
File.write(a, "a\n")
|
|
13
24
|
File.write(b, "b\n")
|
|
14
|
-
session =
|
|
25
|
+
session = get_data_path("session.txt")
|
|
15
26
|
File.write(session, "#{a}\n#{b}\n")
|
|
16
27
|
|
|
17
28
|
open_new_file(startup)
|
|
@@ -19,7 +30,7 @@ class TestStartupFile < VmaTest
|
|
|
19
30
|
ENV["VIMAMSA_RESTORE_SESSION"] = "1"
|
|
20
31
|
begin
|
|
21
32
|
vma.check_session_restore
|
|
22
|
-
|
|
33
|
+
assert wait_until { vma.buffers.get_buffer_by_filename(b) && vma.gui.status_indicator(:session_restore).nil? }
|
|
23
34
|
assert_eq startup, vma.buf.fname
|
|
24
35
|
assert vma.buffers.get_buffer_by_filename(a), "session file a restored"
|
|
25
36
|
assert vma.buffers.get_buffer_by_filename(b), "session file b restored"
|
|
@@ -43,8 +54,9 @@ class TestStartupFile < VmaTest
|
|
|
43
54
|
File.write(a, "a\n")
|
|
44
55
|
File.write(b, "b\n")
|
|
45
56
|
begin
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
done = false
|
|
58
|
+
vma.restore_session_files([a, b]) { done = true }
|
|
59
|
+
assert wait_until { done }, "restore didn't finish"
|
|
48
60
|
assert_eq b, vma.buf.fname
|
|
49
61
|
ensure
|
|
50
62
|
[b, a].each { |f|
|
|
@@ -55,4 +67,33 @@ class TestStartupFile < VmaTest
|
|
|
55
67
|
end
|
|
56
68
|
end
|
|
57
69
|
end
|
|
70
|
+
|
|
71
|
+
# A session opens one file per main loop turn with its progress in the
|
|
72
|
+
# status bar ("Restoring session: 2/5 c.txt"), gone at the end; a file
|
|
73
|
+
# that can't be opened is skipped
|
|
74
|
+
def test_restore_shows_progress
|
|
75
|
+
Dir.mktmpdir do |dir|
|
|
76
|
+
files = %w[a b c d e].map { |n| f = "#{dir}/#{n}.txt"; File.write(f, "#{n}\n"); f }
|
|
77
|
+
bad = "#{dir}/gone.txt" # deleted after the list was made
|
|
78
|
+
seen = []
|
|
79
|
+
done = false
|
|
80
|
+
begin
|
|
81
|
+
vma.restore_session_files(files[0, 2] + [bad] + files[2..]) { done = true }
|
|
82
|
+
assert_eq "Restoring session: 0/6", vma.gui.status_indicator(:session_restore), "no progress before the first file"
|
|
83
|
+
wait_until { seen << vma.gui.status_indicator(:session_restore); done }
|
|
84
|
+
assert done, "restore didn't finish"
|
|
85
|
+
# some file in between (one main loop drain can open several)
|
|
86
|
+
assert seen.compact.any? { |t| t.match?(%r{\ARestoring session: [1-5]/6 }) }, seen.compact.uniq.inspect
|
|
87
|
+
assert_eq nil, vma.gui.status_indicator(:session_restore), "progress still shown"
|
|
88
|
+
files.each { |f| assert vma.buffers.get_buffer_by_filename(f), "#{f} not restored" }
|
|
89
|
+
ensure
|
|
90
|
+
files.each { |f|
|
|
91
|
+
id = vma.buffers.get_buffer_by_filename(f)
|
|
92
|
+
vma.buffers.close_buffer(id) if id
|
|
93
|
+
}
|
|
94
|
+
drain_idle
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
58
99
|
end
|
data/tests/test_text_objects.rb
CHANGED
|
@@ -109,7 +109,7 @@ class TestTextObjects < VmaTest
|
|
|
109
109
|
def test_yank_paragraph_is_linewise
|
|
110
110
|
run_case("p1\np|1b\n\np2", "yip")
|
|
111
111
|
assert_eq "p1\np1b\n", vma.clipboard.get
|
|
112
|
-
assert vma.
|
|
112
|
+
assert vma.registers['"'].linewise, "yip should yank whole lines"
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
def test_delete_puts_text_in_clipboard
|
|
@@ -326,4 +326,16 @@ class TestTextTransforms < VmaTest
|
|
|
326
326
|
assert_buf("a b\nc d\ne f\n")
|
|
327
327
|
assert_mode(:command)
|
|
328
328
|
end
|
|
329
|
+
|
|
330
|
+
# sel.convert.remove_empty_lines: empty and blank lines in the selection go,
|
|
331
|
+
# the rest (and the lines outside it) stay
|
|
332
|
+
def test_remove_empty_lines_selection
|
|
333
|
+
act("buf.insert_txt(\"a\\n\\nb\\n \\nc\\n\\nd\")")
|
|
334
|
+
act("buf.set_pos(0)")
|
|
335
|
+
keys("v")
|
|
336
|
+
act("buf.set_pos(10)") # through the line end after c
|
|
337
|
+
act("sel.convert.remove_empty_lines")
|
|
338
|
+
assert_buf("a\nb\nc\n\nd\n")
|
|
339
|
+
end
|
|
340
|
+
|
|
329
341
|
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# vimamsa --tmp-user-dir: a new user dir in the temp dir, deleted on quit
|
|
2
|
+
# (lib/vimamsa/tmp_user_dir.rb, exe/vimamsa); kill / ctrl-c quit normally
|
|
3
|
+
require "open3"
|
|
4
|
+
require "rbconfig"
|
|
5
|
+
require "tmpdir"
|
|
6
|
+
|
|
7
|
+
class TestTmpUserDir < VmaTest
|
|
8
|
+
EXE = File.expand_path("../exe/vimamsa", __dir__)
|
|
9
|
+
|
|
10
|
+
def test_ours
|
|
11
|
+
d = TmpUserDir.create
|
|
12
|
+
assert TmpUserDir.ours?(d)
|
|
13
|
+
assert File.basename(d).start_with?("vimamsa-user-")
|
|
14
|
+
assert TmpUserDir.delete(d)
|
|
15
|
+
assert !File.exist?(d)
|
|
16
|
+
# never other dirs
|
|
17
|
+
Dir.mktmpdir("other-") { |o|
|
|
18
|
+
assert !TmpUserDir.ours?(o)
|
|
19
|
+
assert !TmpUserDir.delete(o)
|
|
20
|
+
assert File.exist?(o)
|
|
21
|
+
nested = File.join(o, "vimamsa-user-x")
|
|
22
|
+
FileUtils.mkdir_p(nested)
|
|
23
|
+
assert !TmpUserDir.ours?(nested), "not directly in the temp dir"
|
|
24
|
+
}
|
|
25
|
+
assert !TmpUserDir.ours?(nil)
|
|
26
|
+
assert !TmpUserDir.ours?(File.expand_path("~/.config/vimamsa"))
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# A real start: the dir is made, the editor comes up in it (the intro page
|
|
30
|
+
# writes settings.rb), and a TERM quits the editor and deletes the dir
|
|
31
|
+
def test_created_and_deleted_on_quit
|
|
32
|
+
skip "needs a display" unless ENV["DISPLAY"] || ENV["WAYLAND_DISPLAY"]
|
|
33
|
+
out = +""
|
|
34
|
+
dir = nil
|
|
35
|
+
Open3.popen2e(RbConfig.ruby, EXE, "--tmp-user-dir") { |_in, oe, th|
|
|
36
|
+
reader = Thread.new { oe.each_line { |l| out << l } rescue nil }
|
|
37
|
+
t = Time.now
|
|
38
|
+
until (dir = out[/Temporary user dir \(deleted on quit\): (\S+)/, 1]) || Time.now - t > 30
|
|
39
|
+
sleep 0.05
|
|
40
|
+
end
|
|
41
|
+
assert dir, "no dir reported: #{out[-500..]}"
|
|
42
|
+
assert TmpUserDir.ours?(dir)
|
|
43
|
+
t = Time.now
|
|
44
|
+
sleep 0.1 until File.exist?(File.join(dir, "settings.rb")) || !th.alive? || Time.now - t > 60
|
|
45
|
+
assert File.exist?(File.join(dir, "custom.rb")), "editor didn't start in #{dir}: #{out[-800..]}"
|
|
46
|
+
assert File.exist?(File.join(dir, "settings.rb")), "intro not shown at start"
|
|
47
|
+
Process.kill("TERM", th.pid)
|
|
48
|
+
t = Time.now
|
|
49
|
+
sleep 0.1 while th.alive? && Time.now - t < 20
|
|
50
|
+
if th.alive?
|
|
51
|
+
Process.kill("KILL", th.pid)
|
|
52
|
+
assert false, "editor didn't quit on TERM"
|
|
53
|
+
end
|
|
54
|
+
reader.join(2)
|
|
55
|
+
}
|
|
56
|
+
assert !File.exist?(dir), "#{dir} not deleted on quit"
|
|
57
|
+
ensure
|
|
58
|
+
TmpUserDir.delete(dir) if dir
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# A dir with a crash report stays (the report would be lost otherwise)
|
|
62
|
+
def test_kept_with_crash_report
|
|
63
|
+
d = TmpUserDir.create
|
|
64
|
+
FileUtils.mkdir_p(File.join(d, "crash"))
|
|
65
|
+
File.write(File.join(d, "crash", "stderr.log"), "log")
|
|
66
|
+
File.write(File.join(d, "crash", "crash_20261121_000000_1.txt"), "report")
|
|
67
|
+
assert !TmpUserDir.delete(d)
|
|
68
|
+
assert File.exist?(File.join(d, "crash", "crash_20261121_000000_1.txt"))
|
|
69
|
+
FileUtils.rm_f(File.join(d, "crash", "crash_20261121_000000_1.txt"))
|
|
70
|
+
assert TmpUserDir.delete(d), "only stderr.log: deleted"
|
|
71
|
+
assert !File.exist?(d)
|
|
72
|
+
ensure
|
|
73
|
+
FileUtils.rm_rf(d) if d && File.exist?(d)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_help_mentions_it
|
|
77
|
+
assert Vimamsa::CLI_USAGE.include?("--tmp-user-dir")
|
|
78
|
+
end
|
|
79
|
+
end
|
data/tests/test_tts.rb
CHANGED
|
@@ -5,7 +5,7 @@ class TestTts < VmaTest
|
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
def ensure_disabled
|
|
8
|
-
tts_disable if vma.actions.include?(
|
|
8
|
+
tts_disable if vma.actions.include?("tts.speak_selection")
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
# --- _info ---
|
|
@@ -23,10 +23,10 @@ class TestTts < VmaTest
|
|
|
23
23
|
ensure_disabled
|
|
24
24
|
load_tts
|
|
25
25
|
tts_init
|
|
26
|
-
assert vma.actions.include?(
|
|
27
|
-
assert vma.actions.include?(
|
|
28
|
-
assert vma.gui.menu.module_action?(
|
|
29
|
-
assert vma.gui.menu.module_action?(
|
|
26
|
+
assert vma.actions.include?("tts.speak_selection"), "speak action not registered"
|
|
27
|
+
assert vma.actions.include?("tts.stop"), "stop action not registered"
|
|
28
|
+
assert vma.gui.menu.module_action?("tts.speak_selection"), "speak menu item missing"
|
|
29
|
+
assert vma.gui.menu.module_action?("tts.stop"), "stop menu item missing"
|
|
30
30
|
ensure
|
|
31
31
|
tts_disable
|
|
32
32
|
end
|
|
@@ -36,9 +36,9 @@ class TestTts < VmaTest
|
|
|
36
36
|
load_tts
|
|
37
37
|
tts_init
|
|
38
38
|
tts_disable
|
|
39
|
-
assert !vma.actions.include?(
|
|
40
|
-
assert !vma.actions.include?(
|
|
41
|
-
assert !vma.gui.menu.module_action?(
|
|
39
|
+
assert !vma.actions.include?("tts.speak_selection"), "speak action still registered"
|
|
40
|
+
assert !vma.actions.include?("tts.stop"), "stop action still registered"
|
|
41
|
+
assert !vma.gui.menu.module_action?("tts.speak_selection"), "speak menu still present"
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def test_init_disable_cycle
|
|
@@ -46,9 +46,9 @@ class TestTts < VmaTest
|
|
|
46
46
|
load_tts
|
|
47
47
|
3.times do |i|
|
|
48
48
|
tts_init
|
|
49
|
-
assert vma.actions.include?(
|
|
49
|
+
assert vma.actions.include?("tts.speak_selection"), "speak missing after init (cycle #{i})"
|
|
50
50
|
tts_disable
|
|
51
|
-
assert !vma.actions.include?(
|
|
51
|
+
assert !vma.actions.include?("tts.speak_selection"), "speak present after disable (cycle #{i})"
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
data/tests/test_undo.rb
CHANGED
|
@@ -4,47 +4,47 @@ class TestUndo < VmaTest
|
|
|
4
4
|
|
|
5
5
|
def test_undo_restores_empty_buffer
|
|
6
6
|
act 'buf.insert_txt("hello")'
|
|
7
|
-
act
|
|
7
|
+
act "undo.last"
|
|
8
8
|
assert_buf "\n"
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def test_undo_on_empty_buffer_is_noop
|
|
12
|
-
act
|
|
12
|
+
act "undo.last"
|
|
13
13
|
assert_buf "\n"
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def test_redo_after_undo
|
|
17
17
|
act 'buf.insert_txt("hello")'
|
|
18
|
-
act
|
|
19
|
-
act
|
|
18
|
+
act "undo.last"
|
|
19
|
+
act "undo.redo"
|
|
20
20
|
assert_buf "hello\n"
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def test_redo_on_empty_stack_is_noop
|
|
24
|
-
act
|
|
25
|
-
act
|
|
24
|
+
act "undo.last"
|
|
25
|
+
act "undo.redo"
|
|
26
26
|
assert_buf "\n"
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def test_new_edit_clears_redo_stack
|
|
30
30
|
act 'buf.insert_txt("hello")'
|
|
31
|
-
act
|
|
31
|
+
act "undo.last"
|
|
32
32
|
assert_buf "\n"
|
|
33
33
|
act 'buf.insert_txt("world")'
|
|
34
34
|
# redo stack was cleared — redo should be a no-op
|
|
35
|
-
act
|
|
35
|
+
act "undo.redo"
|
|
36
36
|
assert_buf "world\n"
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def test_undo_delete_char
|
|
40
40
|
act 'buf.insert_txt("abcde")'
|
|
41
|
-
act
|
|
41
|
+
act "move.buf.start"
|
|
42
42
|
vma.buf.new_undo_group
|
|
43
|
-
act
|
|
44
|
-
act
|
|
43
|
+
act "edit.delete.char"
|
|
44
|
+
act "edit.delete.char"
|
|
45
45
|
vma.buf.new_undo_group
|
|
46
46
|
assert_buf "cde\n"
|
|
47
|
-
act
|
|
47
|
+
act "undo.last"
|
|
48
48
|
assert_buf "abcde\n"
|
|
49
49
|
end
|
|
50
50
|
|
|
@@ -52,11 +52,11 @@ class TestUndo < VmaTest
|
|
|
52
52
|
act 'buf.insert_txt("first\n")'
|
|
53
53
|
act 'buf.insert_txt("second")'
|
|
54
54
|
vma.buf.new_undo_group
|
|
55
|
-
act
|
|
56
|
-
act
|
|
55
|
+
act "move.buf.start"
|
|
56
|
+
act "edit.delete.line"
|
|
57
57
|
vma.buf.new_undo_group
|
|
58
58
|
assert_buf "second\n"
|
|
59
|
-
act
|
|
59
|
+
act "undo.last"
|
|
60
60
|
assert_buf "first\nsecond\n"
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -66,13 +66,13 @@ class TestUndo < VmaTest
|
|
|
66
66
|
act 'buf.insert_txt(" second")'
|
|
67
67
|
assert_buf "first second\n"
|
|
68
68
|
|
|
69
|
-
act
|
|
69
|
+
act "undo.last"
|
|
70
70
|
assert_buf "first\n"
|
|
71
|
-
act
|
|
71
|
+
act "undo.redo"
|
|
72
72
|
assert_buf "first second\n"
|
|
73
|
-
act
|
|
73
|
+
act "undo.last"
|
|
74
74
|
assert_buf "first\n"
|
|
75
|
-
act
|
|
75
|
+
act "undo.last"
|
|
76
76
|
assert_buf "\n"
|
|
77
77
|
end
|
|
78
78
|
|
|
@@ -87,11 +87,11 @@ class TestUndo < VmaTest
|
|
|
87
87
|
vma.buf.new_undo_group
|
|
88
88
|
assert_buf "aaabbbccc\n"
|
|
89
89
|
|
|
90
|
-
act
|
|
90
|
+
act "undo.last"
|
|
91
91
|
assert_buf "aaabbb\n"
|
|
92
|
-
act
|
|
92
|
+
act "undo.last"
|
|
93
93
|
assert_buf "aaa\n"
|
|
94
|
-
act
|
|
94
|
+
act "undo.last"
|
|
95
95
|
assert_buf "\n"
|
|
96
96
|
end
|
|
97
97
|
|
|
@@ -103,9 +103,9 @@ class TestUndo < VmaTest
|
|
|
103
103
|
keys "i space w o r l d esc"
|
|
104
104
|
assert_buf "hello world\n"
|
|
105
105
|
|
|
106
|
-
act
|
|
106
|
+
act "undo.last"
|
|
107
107
|
assert_buf "hello\n" # second insert session (" world") undone
|
|
108
|
-
act
|
|
108
|
+
act "undo.last"
|
|
109
109
|
assert_buf "\n" # first insert session ("hello") undone
|
|
110
110
|
end
|
|
111
111
|
|
|
@@ -121,7 +121,7 @@ class TestUndo < VmaTest
|
|
|
121
121
|
drain_idle
|
|
122
122
|
assert_buf "line1\nline2\nline3\n"
|
|
123
123
|
|
|
124
|
-
act
|
|
124
|
+
act "undo.last"
|
|
125
125
|
assert_buf "\n"
|
|
126
126
|
end
|
|
127
127
|
|
|
@@ -133,9 +133,9 @@ class TestUndo < VmaTest
|
|
|
133
133
|
drain_idle
|
|
134
134
|
assert_buf "abcdef\n"
|
|
135
135
|
|
|
136
|
-
act
|
|
136
|
+
act "undo.last"
|
|
137
137
|
assert_buf "abc\n"
|
|
138
|
-
act
|
|
138
|
+
act "undo.last"
|
|
139
139
|
assert_buf "\n"
|
|
140
140
|
end
|
|
141
141
|
|
|
@@ -147,9 +147,9 @@ class TestUndo < VmaTest
|
|
|
147
147
|
drain_idle
|
|
148
148
|
assert_buf "base appended\n"
|
|
149
149
|
|
|
150
|
-
act
|
|
150
|
+
act "undo.last"
|
|
151
151
|
assert_buf "base\n"
|
|
152
|
-
act
|
|
152
|
+
act "undo.last"
|
|
153
153
|
assert_buf "\n"
|
|
154
154
|
end
|
|
155
155
|
|
|
@@ -165,9 +165,9 @@ class TestUndo < VmaTest
|
|
|
165
165
|
drain_idle
|
|
166
166
|
assert_buf "foofoo\n"
|
|
167
167
|
|
|
168
|
-
act
|
|
168
|
+
act "undo.last" # undo the macro run
|
|
169
169
|
assert_buf "foo\n"
|
|
170
|
-
act
|
|
170
|
+
act "undo.last" # undo the recording-time insertion
|
|
171
171
|
assert_buf "\n"
|
|
172
172
|
end
|
|
173
173
|
|
|
@@ -176,9 +176,9 @@ class TestUndo < VmaTest
|
|
|
176
176
|
drain_idle
|
|
177
177
|
assert_buf "hello\n"
|
|
178
178
|
|
|
179
|
-
act
|
|
179
|
+
act "undo.last"
|
|
180
180
|
assert_buf "\n"
|
|
181
|
-
act
|
|
181
|
+
act "undo.redo"
|
|
182
182
|
assert_buf "hello\n"
|
|
183
183
|
end
|
|
184
184
|
|
|
@@ -194,7 +194,7 @@ class TestUndo < VmaTest
|
|
|
194
194
|
drain_idle
|
|
195
195
|
assert_buf " world\n"
|
|
196
196
|
|
|
197
|
-
act
|
|
197
|
+
act "undo.last"
|
|
198
198
|
assert_buf "hello world\n"
|
|
199
199
|
end
|
|
200
200
|
|