vimamsa 0.1.26 → 0.1.28
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 +93 -0
- data/.gitignore +4 -1
- data/Dockerfile +7 -4
- data/README.md +195 -99
- data/custom_example.rb +59 -17
- data/doc/TODO.md +678 -0
- data/doc/action_names_plan.md +442 -0
- data/doc/bundling_plan.md +570 -0
- 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 +213 -0
- data/doc/line_tree_plan.md +89 -0
- data/doc/missing_vim_bindings.md +61 -0
- data/doc/modules_settings_plan.md +433 -0
- data/doc/refactor_dedup_plan.md +117 -0
- data/doc/registries_plan.md +202 -0
- data/doc/startup_speed_plan.md +97 -0
- data/doc/treap_visualizer.html +585 -0
- data/doc/unused_code_plan.md +120 -0
- data/doc/vim_compatibility_plan.md +451 -0
- data/doc/vimlike_vim_conflicts.md +262 -0
- data/doc/vm_snapshots_plan.md +146 -0
- data/doc/wysiwyg_plan.md +231 -0
- data/exe/run_tests.rb +124 -3
- data/exe/vimamsa +68 -5
- data/fonts/OFL-Oxanium.txt +93 -0
- data/fonts/Oxanium[wght].ttf +0 -0
- data/help/intro.txt +30 -0
- data/help/vim_intro.txt +31 -0
- data/icon.png +0 -0
- data/img/demo.gif +0 -0
- data/img/demo.mp4 +0 -0
- data/lang/hyperplaintext.lang +7 -1
- data/lib/vimamsa/ack.rb +13 -1
- data/lib/vimamsa/actions.rb +385 -37
- data/lib/vimamsa/appimage_env.rb +35 -0
- data/lib/vimamsa/audio.rb +2 -5
- data/lib/vimamsa/bookmarks.rb +302 -0
- data/lib/vimamsa/buffer.rb +675 -118
- data/lib/vimamsa/buffer_changetext.rb +150 -68
- data/lib/vimamsa/buffer_cursor.rb +7 -0
- data/lib/vimamsa/buffer_list.rb +6 -2
- data/lib/vimamsa/buffer_manager.rb +10 -7
- data/lib/vimamsa/bundled_fonts.rb +32 -0
- data/lib/vimamsa/cli_help.rb +75 -0
- data/lib/vimamsa/clipboard.rb +9 -3
- data/lib/vimamsa/conf.rb +68 -3
- data/lib/vimamsa/constants.rb +3 -0
- data/lib/vimamsa/crash_handler.rb +149 -0
- data/lib/vimamsa/debug.rb +6 -3
- data/lib/vimamsa/demo_player.rb +458 -0
- data/lib/vimamsa/demo_recorder.rb +277 -0
- data/lib/vimamsa/desktop_install.rb +96 -0
- data/lib/vimamsa/diff_buffer.rb +40 -11
- data/lib/vimamsa/dot_repeat.rb +104 -0
- data/lib/vimamsa/easy_jump.rb +57 -3
- data/lib/vimamsa/editor.rb +327 -78
- data/lib/vimamsa/encrypt.rb +78 -29
- data/lib/vimamsa/file_finder.rb +4 -19
- data/lib/vimamsa/file_history.rb +4 -1
- data/lib/vimamsa/file_manager.rb +46 -31
- data/lib/vimamsa/fold.rb +226 -0
- data/lib/vimamsa/form_input.rb +388 -0
- data/lib/vimamsa/gui.rb +603 -119
- data/lib/vimamsa/gui_command_line.rb +247 -0
- data/lib/vimamsa/gui_dialog.rb +94 -42
- data/lib/vimamsa/gui_file_panel.rb +356 -25
- data/lib/vimamsa/gui_form_generator.rb +75 -40
- data/lib/vimamsa/gui_func_panel.rb +67 -22
- data/lib/vimamsa/gui_image.rb +3 -0
- data/lib/vimamsa/gui_key_hint.rb +165 -0
- data/lib/vimamsa/gui_keylog_panel.rb +408 -0
- data/lib/vimamsa/gui_menu.rb +84 -53
- data/lib/vimamsa/gui_select_window.rb +80 -75
- data/lib/vimamsa/gui_settings.rb +86 -41
- data/lib/vimamsa/gui_sourceview.rb +280 -92
- data/lib/vimamsa/gui_sourceview_autocomplete.rb +319 -90
- data/lib/vimamsa/gui_text.rb +63 -2
- data/lib/vimamsa/gui_theme.rb +615 -0
- data/lib/vimamsa/hook.rb +5 -0
- data/lib/vimamsa/hyper_plain_text.rb +3 -0
- data/lib/vimamsa/intro_page.rb +368 -0
- data/lib/vimamsa/key_actions.rb +382 -193
- data/lib/vimamsa/key_binding_tree.rb +467 -273
- data/lib/vimamsa/key_bindings_notepad.rb +45 -0
- data/lib/vimamsa/key_bindings_report.rb +484 -0
- data/lib/vimamsa/key_bindings_vim.rb +104 -0
- data/lib/vimamsa/key_bindings_vimlike.rb +353 -289
- data/lib/vimamsa/key_names.rb +80 -0
- data/lib/vimamsa/langservp.rb +271 -54
- data/lib/vimamsa/line_tree.rb +367 -0
- data/lib/vimamsa/macro.rb +23 -3
- data/lib/vimamsa/main.rb +14 -8
- data/lib/vimamsa/rbvma.rb +41 -1
- data/lib/vimamsa/registers.rb +125 -0
- data/lib/vimamsa/run_ruby.rb +64 -0
- data/lib/vimamsa/search.rb +3 -0
- data/lib/vimamsa/search_replace.rb +15 -14
- data/lib/vimamsa/string_util.rb +134 -40
- data/lib/vimamsa/terminal.rb +3 -0
- data/lib/vimamsa/test_framework.rb +28 -2
- data/lib/vimamsa/tests.rb +11 -8
- data/lib/vimamsa/text_objects.rb +310 -0
- data/lib/vimamsa/text_transforms.rb +18 -0
- data/lib/vimamsa/tmp_user_dir.rb +39 -0
- data/lib/vimamsa/user_dirs.rb +83 -0
- data/lib/vimamsa/util.rb +46 -7
- data/lib/vimamsa/version.rb +1 -1
- data/lib/vimamsa/vim_core.rb +355 -0
- data/lib/vimamsa/vim_operators.rb +365 -0
- data/lib/vimamsa.rb +0 -1
- data/modules/calculator/calculator.rb +5 -5
- data/modules/color_highlight/color_highlight.rb +118 -0
- data/modules/color_highlight/color_highlight_info.rb +3 -0
- data/modules/dictation/dictation.rb +1054 -0
- data/modules/dictation/dictation_info.rb +3 -0
- data/modules/dictation/whisper_worker.py +273 -0
- data/modules/ollama/ollama.rb +107 -0
- data/modules/ollama/ollama_info.rb +3 -0
- data/modules/terminal/terminal.rb +5 -5
- data/modules/tts/tts.rb +119 -0
- data/modules/tts/tts_info.rb +3 -0
- data/run_e2e_vm.sh +28 -0
- data/run_tests_vm.rb +138 -0
- data/scripts/appimage/AppRun +54 -0
- data/scripts/appimage/Dockerfile +18 -0
- data/scripts/appimage/build.sh +19 -0
- data/scripts/appimage/build_in_container.sh +192 -0
- data/scripts/appimage/smoke_test.sh +27 -0
- data/scripts/demo/demo_easyjump_steps.txt +60 -0
- data/scripts/demo/demo_files_steps.txt +52 -0
- data/scripts/demo/demo_steps.txt +67 -0
- data/scripts/demo/notes.txt +6 -0
- data/scripts/demo/record_demo.rb +156 -0
- data/scripts/demo/report.rb +7 -0
- data/scripts/demo/shapes.rb +29 -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/styles/134272-molokai.xml +3 -0
- data/styles/molokai_cyber.xml +48 -0
- data/styles/molokai_edit.xml +1 -0
- data/tests/support/virtual_keyboard.rb +254 -0
- data/tests/support/virtual_mic.rb +67 -0
- data/tests/test_ack.rb +22 -0
- data/tests/test_action_ids.rb +232 -0
- data/tests/test_auto_format.rb +122 -0
- data/tests/test_autocomplete.rb +211 -0
- data/tests/test_autosave.rb +145 -0
- data/tests/test_basic_editing.rb +46 -16
- data/tests/test_bookmarks.rb +206 -0
- data/tests/test_bracket_match.rb +88 -0
- data/tests/test_bundling.rb +92 -0
- data/tests/test_cli_help.rb +64 -0
- data/tests/test_color_highlight.rb +92 -0
- data/tests/test_command_line.rb +79 -0
- data/tests/test_command_line_file.rb +27 -0
- data/tests/test_context_menu_file.rb +147 -0
- data/tests/test_copy_paste.rb +106 -26
- data/tests/test_crash_handler.rb +39 -0
- data/tests/test_custom_two_phase.rb +92 -0
- data/tests/test_demo_player.rb +301 -0
- data/tests/test_demo_recorder.rb +202 -0
- data/tests/test_dialog_callback_errors.rb +44 -0
- data/tests/test_dictation.rb +294 -0
- data/tests/test_diff_buffer_name.rb +51 -0
- data/tests/test_dot_repeat.rb +88 -0
- data/tests/test_double_click.rb +41 -0
- data/tests/test_drag_selection.rb +125 -0
- data/tests/test_e2e_cmdline.rb +116 -0
- data/tests/test_e2e_dictation.rb +98 -0
- data/tests/test_e2e_replace_char.rb +58 -0
- data/tests/test_easy_jump.rb +93 -0
- data/tests/test_extract_file_links.rb +55 -0
- data/tests/test_file_format.rb +217 -0
- data/tests/test_file_manager.rb +72 -0
- data/tests/test_file_panel.rb +269 -0
- data/tests/test_flash.rb +78 -0
- data/tests/test_fold.rb +111 -0
- data/tests/test_font_refresh.rb +56 -0
- data/tests/test_form_input.rb +203 -0
- data/tests/test_func_panel.rb +68 -0
- data/tests/test_grep_apply.rb +46 -0
- data/tests/test_gtk_sync.rb +126 -0
- data/tests/test_hpt_highlight_visible.rb +75 -0
- data/tests/test_hpt_link_highlight.rb +82 -0
- data/tests/test_intro_page.rb +437 -0
- data/tests/test_jump_to_file.rb +41 -0
- data/tests/test_key_bindings.rb +208 -0
- data/tests/test_key_categories.rb +163 -0
- data/tests/test_keylog_panel.rb +261 -0
- data/tests/test_line_ends.rb +51 -0
- data/tests/test_line_tree.rb +86 -0
- data/tests/test_lsp_clangd.rb +281 -0
- data/tests/test_lsp_jump.rb +87 -0
- data/tests/test_lsp_position_encoding.rb +49 -0
- data/tests/test_lsp_symbols.rb +68 -0
- data/tests/test_macro.rb +137 -0
- data/tests/test_markdown_highlight.rb +57 -0
- data/tests/test_mode_badge.rb +41 -0
- data/tests/test_module_interface.rb +9 -9
- data/tests/test_notepad_bindings.rb +67 -0
- data/tests/test_perf_startup.rb +28 -0
- data/tests/test_popup_queue.rb +51 -0
- data/tests/test_random_edit.rb +109 -0
- data/tests/test_registers.rb +122 -0
- data/tests/test_revert.rb +127 -0
- data/tests/test_run_ruby.rb +77 -0
- data/tests/test_startup_file.rb +58 -0
- data/tests/test_status_area.rb +50 -0
- data/tests/test_text_objects.rb +163 -0
- data/tests/test_text_transforms.rb +341 -0
- data/tests/test_tmp_user_dir.rb +79 -0
- data/tests/test_tts.rb +68 -0
- data/tests/test_undo.rb +34 -34
- data/tests/test_user_dirs.rb +122 -0
- data/tests/test_vim_bindings.rb +353 -0
- data/tests/test_vim_conflicts.rb +100 -0
- data/tests/test_vim_operators.rb +116 -0
- data/tests/test_window_layout.rb +302 -0
- data/vimamsa.gemspec +3 -1
- data/vm_guest_run.sh +129 -0
- metadata +167 -10
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# vimamsa --help: the options and the actions, without starting the editor
|
|
2
|
+
# (lib/vimamsa/cli_help.rb)
|
|
3
|
+
require "open3"
|
|
4
|
+
require "rbconfig"
|
|
5
|
+
require "tmpdir"
|
|
6
|
+
|
|
7
|
+
class TestCliHelp < VmaTest
|
|
8
|
+
EXE = File.expand_path("../exe/vimamsa", __dir__)
|
|
9
|
+
|
|
10
|
+
def run_help(*args)
|
|
11
|
+
Dir.mktmpdir("vma-help") { |ud|
|
|
12
|
+
# a running editor's listen dir: --help must not be sent to it as a file
|
|
13
|
+
FileUtils.mkdir_p(File.join(ud, "listen"))
|
|
14
|
+
out, st = Open3.capture2e(RbConfig.ruby, EXE, "--user-dir", ud, *args)
|
|
15
|
+
[out, st, Dir.children(File.join(ud, "listen"))]
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_help_lists_options_and_actions
|
|
20
|
+
skip "needs a display" unless ENV["DISPLAY"] || ENV["WAYLAND_DISPLAY"]
|
|
21
|
+
out, st, listen = run_help("--help")
|
|
22
|
+
assert st.success?, "exit status #{st.exitstatus}: #{out[-500..]}"
|
|
23
|
+
assert_eq [], listen, "--help was passed to a running editor"
|
|
24
|
+
assert out.include?("Usage: vimamsa"), out[0, 300]
|
|
25
|
+
assert out.include?("--intro")
|
|
26
|
+
assert out.include?("--user-dir")
|
|
27
|
+
lines = out.lines.map(&:strip)
|
|
28
|
+
save = lines.find { |l| l.start_with?("buf.save ") }
|
|
29
|
+
assert save, "buf.save not listed"
|
|
30
|
+
assert_eq vma.actions["buf.save"].method_name.to_s, save.sub(/\Abuf\.save\s+/, ""), "description"
|
|
31
|
+
%w[help.intro help.demo move.motion op.motion edit.register].each { |id|
|
|
32
|
+
assert lines.any? { |l| l == id || l.start_with?("#{id} ") }, "#{id} not listed"
|
|
33
|
+
}
|
|
34
|
+
n = out[/Actions \((\d+)\)/, 1].to_i
|
|
35
|
+
listed = lines.select { |l| l.match?(/\A[a-z][a-z0-9_]*(\.[a-z0-9_]+)+(\s|\z)/) }.map { |l| l.split[0] }
|
|
36
|
+
assert_eq n, listed.size
|
|
37
|
+
# all real actions; missing ones only from modules (registered on init)
|
|
38
|
+
# and custom.rb (from custom_example.rb, e.g. the getnums converter)
|
|
39
|
+
live = vma.actions.dotted_ids.map(&:to_s)
|
|
40
|
+
assert_eq [], listed - live, "listed but not actions"
|
|
41
|
+
extra = (Dir[File.expand_path("../modules/*/*.rb", __dir__)] + [File.expand_path("../custom_example.rb", __dir__), get_dot_path("custom.rb")])
|
|
42
|
+
.select { |f| File.exist?(f) }.map { |f| File.read(f) }.join
|
|
43
|
+
missing = (live - listed).reject { |id| extra.include?(id) || extra.include?(":#{id.sub("sel.convert.", "")})") || id.include?("zz_") }
|
|
44
|
+
assert missing.empty?, "actions missing from --help: #{missing.inspect}"
|
|
45
|
+
assert !out.include?("Init_vmaext\n" * 2)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_short_option
|
|
49
|
+
skip "needs a display" unless ENV["DISPLAY"] || ENV["WAYLAND_DISPLAY"]
|
|
50
|
+
out, st, = run_help("-h")
|
|
51
|
+
assert st.success?
|
|
52
|
+
assert out.include?("Usage: vimamsa")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# The list is the same as in the running editor, apart from what modules
|
|
56
|
+
# and custom.rb add
|
|
57
|
+
def test_action_lines_format
|
|
58
|
+
lines = Vimamsa.cli_action_lines(vma.actions)
|
|
59
|
+
assert lines.all? { |l| l.start_with?(" ") }
|
|
60
|
+
ids = lines.map { |l| l.split[0] }
|
|
61
|
+
assert_eq ids.sort, ids
|
|
62
|
+
assert ids.include?("buf.save")
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
class TestColorHighlight < VmaTest
|
|
2
|
+
|
|
3
|
+
def view
|
|
4
|
+
vma.buf.view
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
# Does the GTK buffer carry one of our color tags spanning the given offset?
|
|
8
|
+
def color_tag_at(off)
|
|
9
|
+
itr = view.buffer.get_iter_at(:offset => off)
|
|
10
|
+
itr.tags.find { |t| t.name.to_s.start_with?("vma_color_") }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# ── Pure color math ──────────────────────────────────────────────────────
|
|
14
|
+
|
|
15
|
+
def test_display_colors_six_digit
|
|
16
|
+
bg, fg = Vimamsa::ColorHighlight.display_colors("#3DCBB5")
|
|
17
|
+
assert_eq "#3dcbb5", bg
|
|
18
|
+
assert_eq "#000000", fg, "teal is bright => black text"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_display_colors_dark_gets_white_text
|
|
22
|
+
_bg, fg = Vimamsa::ColorHighlight.display_colors("#101010")
|
|
23
|
+
assert_eq "#ffffff", fg
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_display_colors_shorthand_expands
|
|
27
|
+
bg, _fg = Vimamsa::ColorHighlight.display_colors("#f00")
|
|
28
|
+
assert_eq "#ff0000", bg
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_display_colors_drops_alpha
|
|
32
|
+
bg, _fg = Vimamsa::ColorHighlight.display_colors("#3dcbb5ff")
|
|
33
|
+
assert_eq "#3dcbb5", bg
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# ── Live tagging in the GTK buffer ─────────────────────────────────────────
|
|
37
|
+
|
|
38
|
+
def test_hex_code_gets_a_color_tag
|
|
39
|
+
cnf.modules.color_highlight.enabled = true
|
|
40
|
+
vma.buf.set_content("bg = #3DCBB5\n")
|
|
41
|
+
view.highlight_colors
|
|
42
|
+
idx = vma.buf.to_s.index("#3DCBB5")
|
|
43
|
+
tag = color_tag_at(idx)
|
|
44
|
+
assert !tag.nil?, "expected a vma_color_ tag over the hex code"
|
|
45
|
+
assert_eq "#3dcbb5", tag.name.sub("vma_color_", "")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_non_color_text_untagged
|
|
49
|
+
cnf.modules.color_highlight.enabled = true
|
|
50
|
+
vma.buf.set_content("just words here\n")
|
|
51
|
+
view.highlight_colors
|
|
52
|
+
assert color_tag_at(2).nil?, "plain text must not get a color tag"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_disabled_clears_tags
|
|
56
|
+
cnf.modules.color_highlight.enabled = true
|
|
57
|
+
vma.buf.set_content("c = #ff0000\n")
|
|
58
|
+
view.highlight_colors
|
|
59
|
+
idx = vma.buf.to_s.index("#ff0000")
|
|
60
|
+
assert !color_tag_at(idx).nil?, "tag should be present while enabled"
|
|
61
|
+
cnf.modules.color_highlight.enabled = false
|
|
62
|
+
view.highlight_colors
|
|
63
|
+
assert color_tag_at(idx).nil?, "disabling must remove color tags"
|
|
64
|
+
ensure
|
|
65
|
+
cnf.modules.color_highlight.enabled = true
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def test_toggle_action
|
|
69
|
+
prev = cnf.modules.color_highlight.enabled?
|
|
70
|
+
cnf.modules.color_highlight.enabled = true
|
|
71
|
+
act "color_highlight.toggle"
|
|
72
|
+
assert_eq false, cnf.modules.color_highlight.enabled?
|
|
73
|
+
act "color_highlight.toggle"
|
|
74
|
+
assert_eq true, cnf.modules.color_highlight.enabled?
|
|
75
|
+
ensure
|
|
76
|
+
cnf.modules.color_highlight.enabled = prev
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# The module decouples from core via view hooks rather than direct calls.
|
|
80
|
+
def test_view_hooks_registered
|
|
81
|
+
assert vma.hook[:view_content_set]&.any?, "content-set hook should be registered"
|
|
82
|
+
assert vma.hook[:view_text_changed]&.any?, "text-changed hook should be registered"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Exposed in the Preferences dialog as an auto-discovered module toggle.
|
|
86
|
+
def test_setting_exposed
|
|
87
|
+
all = all_settings_defs.flat_map { |sec| sec[:settings] }
|
|
88
|
+
s = all.find { |x| x[:key] == [:modules, :color_highlight, :enabled] }
|
|
89
|
+
assert !s.nil?, "color_highlight module toggle must appear in settings defs"
|
|
90
|
+
assert_eq :bool, s[:type]
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
class TestCommandLine < VmaTest
|
|
2
|
+
def cl
|
|
3
|
+
vma.gui.cmd_line
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def last_message
|
|
7
|
+
vma.gui.instance_variable_get(:@minibuf_messages).first.to_s
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_ruby_eval_echoes_result
|
|
11
|
+
cl.execute("21 * 2")
|
|
12
|
+
drain_idle
|
|
13
|
+
assert last_message.include?("=> 42"), "eval result echoed, got: #{last_message.inspect}"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_ruby_can_edit_buffer
|
|
17
|
+
cl.execute("buf.insert_txt('hello')")
|
|
18
|
+
drain_idle
|
|
19
|
+
assert_buf "hello\n"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_config_change_via_ruby
|
|
23
|
+
prev = cnf.tab.width!
|
|
24
|
+
cl.execute("cnf.tab.width = 8")
|
|
25
|
+
assert_eq 8, cnf.tab.width!, "config changed via command line"
|
|
26
|
+
ensure
|
|
27
|
+
cnf.tab.width = prev
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_ruby_error_is_caught
|
|
31
|
+
cl.execute("nonexistent_method_xyz_123")
|
|
32
|
+
drain_idle
|
|
33
|
+
assert last_message.include?("ERROR:"), "error shown, got: #{last_message.inspect}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_ruby_syntax_error_is_caught
|
|
37
|
+
cl.execute("def broken(")
|
|
38
|
+
drain_idle
|
|
39
|
+
assert last_message.include?("ERROR:"), "syntax error shown, got: #{last_message.inspect}"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_bare_number_jumps_to_line
|
|
43
|
+
vma.buf.set_content("one\ntwo\nthree\nfour\nfive\n")
|
|
44
|
+
drain_idle
|
|
45
|
+
cl.execute("3")
|
|
46
|
+
drain_idle
|
|
47
|
+
assert_eq 2, vma.buf.lpos, "jumped to line 3 (lpos 2)"
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_shell_command_output_to_buffer
|
|
51
|
+
cl.execute("!echo vmatest_shell_output")
|
|
52
|
+
found = false
|
|
53
|
+
50.times do
|
|
54
|
+
drain_idle
|
|
55
|
+
if vma.buf.to_s.include?("vmatest_shell_output")
|
|
56
|
+
found = true
|
|
57
|
+
break
|
|
58
|
+
end
|
|
59
|
+
sleep 0.1
|
|
60
|
+
end
|
|
61
|
+
assert found, "shell output opened in a new buffer"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_history_records_commands
|
|
65
|
+
cl.execute("1 + 1")
|
|
66
|
+
cl.execute("2 + 2")
|
|
67
|
+
assert_eq "2 + 2", cl.history.last, "newest command last in history"
|
|
68
|
+
assert cl.history.include?("1 + 1"), "older command kept in history"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_open_and_close
|
|
72
|
+
act "mode.cmdline"
|
|
73
|
+
stack = vma.gui.instance_variable_get(:@minibuf_stack)
|
|
74
|
+
assert_eq "cmdline", stack.visible_child_name, "command line shown"
|
|
75
|
+
cl.close
|
|
76
|
+
drain_idle
|
|
77
|
+
assert stack.visible_child_name != "cmdline", "command line hidden after close"
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "tmpdir"
|
|
2
|
+
|
|
3
|
+
class TestCommandLineFile < VmaTest
|
|
4
|
+
def test_missing_command_line_file_is_not_created
|
|
5
|
+
Dir.mktmpdir do |dir|
|
|
6
|
+
path = File.join(dir, "created.txt")
|
|
7
|
+
|
|
8
|
+
result = open_new_file(path)
|
|
9
|
+
|
|
10
|
+
assert !result, "opening a missing file should not return a buffer"
|
|
11
|
+
assert !File.exist?(path), "missing command-line path should not be created"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_existing_command_line_file_keeps_its_contents
|
|
16
|
+
Dir.mktmpdir do |dir|
|
|
17
|
+
path = File.join(dir, "existing.txt")
|
|
18
|
+
File.write(path, "existing contents\n")
|
|
19
|
+
|
|
20
|
+
open_new_file(path)
|
|
21
|
+
|
|
22
|
+
assert_eq path, vma.buf.fname
|
|
23
|
+
assert_eq "existing contents\n", vma.buf.to_s
|
|
24
|
+
assert_eq "existing contents\n", File.read(path)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
require "tmpdir"
|
|
2
|
+
|
|
3
|
+
# Right-clicking text that names an existing file offers to open it.
|
|
4
|
+
class TestContextMenuFile < VmaTest
|
|
5
|
+
def menu_labels(view)
|
|
6
|
+
m = view.instance_variable_get(:@context_menu).menu_model
|
|
7
|
+
(0...m.n_items).map { |i| m.get_item_attribute_value(i, "label", GLib::VariantType::STRING) }
|
|
8
|
+
ensure
|
|
9
|
+
view.instance_variable_get(:@context_menu)&.popdown
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Buffer for dir/notes.txt whose first word is first_word; right-click on it.
|
|
13
|
+
def with_menu(first_word)
|
|
14
|
+
Dir.mktmpdir do |dir|
|
|
15
|
+
File.binwrite("#{dir}/foobar.pdf", "%PDF-1.4\n%\xE2\xE3\xCF\xD3\n\xFF\xFEbinary".b)
|
|
16
|
+
File.write("#{dir}/other.txt", "hello\n")
|
|
17
|
+
path = "#{dir}/notes.txt"
|
|
18
|
+
File.write(path, "#{first_word} rest of line\n")
|
|
19
|
+
b = open_new_file(path)
|
|
20
|
+
begin
|
|
21
|
+
drain_idle
|
|
22
|
+
# Point inside the first word (widget x 5 is in the line-number gutter)
|
|
23
|
+
x, y = b.view.buffer_to_window_coords(:widget, 5, 5)
|
|
24
|
+
b.view.show_context_menu(x, y)
|
|
25
|
+
drain_idle
|
|
26
|
+
yield b, menu_labels(b.view), dir
|
|
27
|
+
ensure
|
|
28
|
+
vma.buffers.close_buffer(b.id)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_binary_file_opens_externally
|
|
34
|
+
with_menu("foobar.pdf") do |b, labels, dir|
|
|
35
|
+
assert labels.include?("Open file (external)"), labels.inspect
|
|
36
|
+
assert !labels.include?("Open file"), labels.inspect
|
|
37
|
+
opened = nil
|
|
38
|
+
orig = Vimamsa.instance_method(:open_with_default_program)
|
|
39
|
+
Vimamsa.send(:define_method, :open_with_default_program) { |p| opened = p }
|
|
40
|
+
begin
|
|
41
|
+
vma.gui.app.lookup_action("ctx_open_file_external").activate(nil)
|
|
42
|
+
drain_idle
|
|
43
|
+
ensure
|
|
44
|
+
Vimamsa.send(:define_method, :open_with_default_program, orig)
|
|
45
|
+
end
|
|
46
|
+
assert_eq File.join(dir, "foobar.pdf"), opened
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def test_text_file_can_open_in_editor
|
|
51
|
+
with_menu("(other.txt).") do |b, labels, dir|
|
|
52
|
+
assert labels.include?("Open file"), labels.inspect
|
|
53
|
+
assert labels.include?("Open file (external)"), labels.inspect
|
|
54
|
+
vma.gui.app.lookup_action("ctx_open_file").activate(nil)
|
|
55
|
+
drain_idle
|
|
56
|
+
assert_eq File.join(dir, "other.txt"), vma.buf.fname
|
|
57
|
+
vma.buffers.close_buffer(vma.buf.id)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# ⟦help:keybindings⟧ opened from the context menu shows the key bindings,
|
|
62
|
+
# like opening it with the keyboard does
|
|
63
|
+
def test_help_link_opens_from_menu
|
|
64
|
+
with_menu("⟦help:keybindings⟧") do |_b, labels, _dir|
|
|
65
|
+
assert labels.include?("Open link"), labels.inspect
|
|
66
|
+
called = nil
|
|
67
|
+
orig = Vimamsa.instance_method(:call_action)
|
|
68
|
+
Vimamsa.send(:define_method, :call_action) { |id, *a| called = id }
|
|
69
|
+
begin
|
|
70
|
+
vma.gui.app.lookup_action("ctx_open_link").activate(nil)
|
|
71
|
+
drain_idle
|
|
72
|
+
ensure
|
|
73
|
+
Vimamsa.send(:define_method, :call_action, orig)
|
|
74
|
+
end
|
|
75
|
+
assert_eq "help.keys", called
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_no_item_for_missing_file
|
|
80
|
+
with_menu("missing.pdf") do |_b, labels, _dir|
|
|
81
|
+
assert !labels.any? { |l| l.start_with?("Open file") }, labels.inspect
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# gf opens the file whose path is under the cursor (like vim)
|
|
86
|
+
def test_gf_opens_file_under_cursor
|
|
87
|
+
Dir.mktmpdir do |dir|
|
|
88
|
+
File.write("#{dir}/other.txt", "hello\n")
|
|
89
|
+
File.write("#{dir}/n.txt", "see (other.txt). missing.txt\n")
|
|
90
|
+
b = open_new_file("#{dir}/n.txt")
|
|
91
|
+
begin
|
|
92
|
+
drain_idle
|
|
93
|
+
b.set_pos(b.to_s.index("other.txt") + 3)
|
|
94
|
+
keys("g f")
|
|
95
|
+
drain_idle
|
|
96
|
+
assert_eq File.join(dir, "other.txt"), vma.buf.fname
|
|
97
|
+
vma.buffers.close_buffer(vma.buf.id)
|
|
98
|
+
drain_idle
|
|
99
|
+
|
|
100
|
+
vma.buffers.set_current_buffer(b.id) if vma.buf != b
|
|
101
|
+
b.set_pos(b.to_s.index("missing.txt") + 2)
|
|
102
|
+
keys("g f")
|
|
103
|
+
drain_idle
|
|
104
|
+
assert_eq b.fname, vma.buf.fname
|
|
105
|
+
ensure
|
|
106
|
+
vma.buffers.close_buffer(b.id)
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_gf_opens_binary_file_externally
|
|
112
|
+
Dir.mktmpdir do |dir|
|
|
113
|
+
File.binwrite("#{dir}/foobar.pdf", "%PDF-1.4\n%\xE2\xE3\xCF\xD3\n\xFF\xFEbinary".b)
|
|
114
|
+
File.write("#{dir}/n.txt", "foobar.pdf\n")
|
|
115
|
+
b = open_new_file("#{dir}/n.txt")
|
|
116
|
+
opened = nil
|
|
117
|
+
orig = Vimamsa.instance_method(:open_with_default_program)
|
|
118
|
+
Vimamsa.send(:define_method, :open_with_default_program) { |p| opened = p }
|
|
119
|
+
begin
|
|
120
|
+
drain_idle
|
|
121
|
+
b.set_pos(2)
|
|
122
|
+
keys("g f")
|
|
123
|
+
drain_idle
|
|
124
|
+
assert_eq File.join(dir, "foobar.pdf"), opened
|
|
125
|
+
ensure
|
|
126
|
+
Vimamsa.send(:define_method, :open_with_default_program, orig)
|
|
127
|
+
vma.buffers.close_buffer(b.id)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def test_file_path_at
|
|
133
|
+
Dir.mktmpdir do |dir|
|
|
134
|
+
File.write("#{dir}/a.pdf", "x")
|
|
135
|
+
b = open_new_file(File.write("#{dir}/n.txt", "see \"a.pdf\", and #{dir}/a.pdf b.pdf\n") && "#{dir}/n.txt")
|
|
136
|
+
begin
|
|
137
|
+
s = b.to_s
|
|
138
|
+
assert_eq "#{dir}/a.pdf", b.file_path_at(s.index("a.pdf"))
|
|
139
|
+
assert_eq "#{dir}/a.pdf", b.file_path_at(s.index("#{dir}/a.pdf") + 2)
|
|
140
|
+
assert_eq nil, b.file_path_at(s.index("b.pdf"))
|
|
141
|
+
assert_eq nil, b.file_path_at(s.index("see"))
|
|
142
|
+
ensure
|
|
143
|
+
vma.buffers.close_buffer(b.id)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
data/tests/test_copy_paste.rb
CHANGED
|
@@ -1,57 +1,79 @@
|
|
|
1
1
|
class TestCopyPaste < VmaTest
|
|
2
2
|
|
|
3
|
+
# On Wayland, read_text_async reads from whatever process currently owns the
|
|
4
|
+
# system clipboard. GTK processes Wayland events during drain_idle and may
|
|
5
|
+
# transfer clipboard ownership to another app between our set_system_clipboard
|
|
6
|
+
# call and the async read callback, returning stale external content.
|
|
7
|
+
#
|
|
8
|
+
# Tests only need to verify in-editor copy/paste logic, not cross-app
|
|
9
|
+
# clipboard round-trips, so we force the synchronous internal-clipboard path
|
|
10
|
+
# (the same one used during macro playback) for all paste actions.
|
|
11
|
+
PASTE_ACTIONS = %i[paste_after_cursor paste_before_cursor
|
|
12
|
+
paste_over_after paste_over_before].freeze
|
|
13
|
+
|
|
14
|
+
def act(action)
|
|
15
|
+
if PASTE_ACTIONS.include?(action)
|
|
16
|
+
vma.macro.instance_variable_set(:@running_macro, true)
|
|
17
|
+
exec_action(action)
|
|
18
|
+
vma.macro.instance_variable_set(:@running_macro, false)
|
|
19
|
+
drain_idle
|
|
20
|
+
else
|
|
21
|
+
super
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
3
25
|
def test_copy_line_paste_after
|
|
4
26
|
act 'buf.insert_txt("hello\n")'
|
|
5
|
-
act
|
|
6
|
-
act
|
|
7
|
-
act
|
|
8
|
-
act
|
|
27
|
+
act "move.buf.start"
|
|
28
|
+
act "edit.line.copy"
|
|
29
|
+
act "move.buf.end"
|
|
30
|
+
act "edit.paste.after"
|
|
9
31
|
assert_buf "hello\n\nhello\n"
|
|
10
32
|
end
|
|
11
33
|
|
|
12
34
|
def test_copy_line_paste_before
|
|
13
35
|
act 'buf.insert_txt("hello\n")'
|
|
14
36
|
act 'buf.insert_txt("world")'
|
|
15
|
-
act
|
|
16
|
-
act
|
|
37
|
+
act "move.buf.start"
|
|
38
|
+
act "edit.line.copy"
|
|
17
39
|
act "buf.move(FORWARD_LINE)"
|
|
18
|
-
act
|
|
40
|
+
act "edit.paste.before"
|
|
19
41
|
assert_buf "hello\nhello\nworld\n"
|
|
20
42
|
end
|
|
21
43
|
|
|
22
44
|
def test_copy_paste_twice
|
|
23
45
|
act 'buf.insert_txt("abc")'
|
|
24
|
-
act
|
|
25
|
-
act
|
|
26
|
-
act
|
|
27
|
-
act
|
|
28
|
-
act
|
|
46
|
+
act "move.buf.start"
|
|
47
|
+
act "edit.line.copy"
|
|
48
|
+
act "move.buf.end"
|
|
49
|
+
act "edit.paste.after"
|
|
50
|
+
act "edit.paste.after"
|
|
29
51
|
assert_buf "abc\nabc\nabc\n"
|
|
30
52
|
end
|
|
31
53
|
|
|
32
54
|
def test_cut_selection_paste
|
|
33
55
|
act 'buf.insert_txt("hello world")'
|
|
34
|
-
act
|
|
56
|
+
act "move.buf.start"
|
|
35
57
|
# Select "hello" (5 chars)
|
|
36
58
|
act "buf.start_selection"
|
|
37
59
|
4.times { act "buf.move(FORWARD_CHAR)" }
|
|
38
|
-
act
|
|
60
|
+
act "sel.cut"
|
|
39
61
|
assert_buf " world\n"
|
|
40
62
|
act "buf.jump(END_OF_LINE)"
|
|
41
|
-
act
|
|
63
|
+
act "edit.paste.after"
|
|
42
64
|
assert_buf " worldhello\n"
|
|
43
65
|
end
|
|
44
66
|
|
|
45
67
|
def test_copy_selection_paste
|
|
46
68
|
act 'buf.insert_txt("foo bar")'
|
|
47
|
-
act
|
|
69
|
+
act "move.buf.start"
|
|
48
70
|
act "buf.start_selection"
|
|
49
71
|
2.times { act "buf.move(FORWARD_CHAR)" }
|
|
50
|
-
act
|
|
72
|
+
act "sel.copy"
|
|
51
73
|
# Original buffer unchanged
|
|
52
74
|
assert_buf "foo bar\n"
|
|
53
75
|
act "buf.jump(END_OF_LINE)"
|
|
54
|
-
act
|
|
76
|
+
act "edit.paste.after"
|
|
55
77
|
assert_buf "foo barfoo\n"
|
|
56
78
|
end
|
|
57
79
|
|
|
@@ -62,27 +84,85 @@ class TestCopyPaste < VmaTest
|
|
|
62
84
|
|
|
63
85
|
def test_copy_line_updates_clipboard
|
|
64
86
|
act 'buf.insert_txt("myline")'
|
|
65
|
-
act
|
|
66
|
-
act
|
|
87
|
+
act "move.buf.start"
|
|
88
|
+
act "edit.line.copy"
|
|
67
89
|
assert_eq "myline\n", vma.clipboard.get
|
|
68
90
|
end
|
|
69
91
|
|
|
70
92
|
def test_cut_selection_updates_clipboard
|
|
71
93
|
act 'buf.insert_txt("hello")'
|
|
72
|
-
act
|
|
94
|
+
act "move.buf.start"
|
|
73
95
|
act "buf.start_selection"
|
|
74
96
|
2.times { act "buf.move(FORWARD_CHAR)" }
|
|
75
|
-
act
|
|
97
|
+
act "sel.cut"
|
|
76
98
|
assert_eq "hel", vma.clipboard.get
|
|
77
99
|
end
|
|
78
100
|
|
|
79
101
|
def test_paste_multiline
|
|
80
102
|
act 'buf.insert_txt("line1\nline2\nline3")'
|
|
81
|
-
act
|
|
82
|
-
act
|
|
83
|
-
act
|
|
84
|
-
act
|
|
103
|
+
act "move.buf.start"
|
|
104
|
+
act "edit.line.copy"
|
|
105
|
+
act "move.buf.end"
|
|
106
|
+
act "edit.paste.after"
|
|
85
107
|
assert_buf "line1\nline2\nline3\nline1\n"
|
|
86
108
|
end
|
|
87
109
|
|
|
110
|
+
# --- Async paste position capture ------------------------------------------
|
|
111
|
+
# paste_start reads the clipboard asynchronously; its callback (paste_finish)
|
|
112
|
+
# may run after the cursor has moved. These tests drive paste_finish directly
|
|
113
|
+
# with the position/state captured at request time (ipos/paste_lines) while
|
|
114
|
+
# the live cursor sits elsewhere, simulating that race. The paste must land
|
|
115
|
+
# where it was initiated, not at the moved cursor.
|
|
116
|
+
|
|
117
|
+
def test_async_paste_inserts_at_captured_position
|
|
118
|
+
act 'buf.insert_txt("line one\nline two\n")'
|
|
119
|
+
act "move.buf.start"
|
|
120
|
+
ipos = buf.pos # where the user pressed paste
|
|
121
|
+
vma.clipboard << "X"
|
|
122
|
+
act "move.buf.end" # cursor moves away during the async read
|
|
123
|
+
buf.paste_finish("X", AFTER, nil, ipos: ipos)
|
|
124
|
+
assert_buf "lXine one\nline two\n\n"
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def test_async_paste_line_mode_uses_captured_state
|
|
128
|
+
act 'buf.insert_txt("AAA\nBBB\nCCC\n")'
|
|
129
|
+
act "move.buf.start"
|
|
130
|
+
act "edit.line.copy" # clipboard = "AAA\n", @paste_lines = true
|
|
131
|
+
ipos = buf.pos
|
|
132
|
+
act "move.buf.end" # cursor moves to the last line
|
|
133
|
+
buf.paste_finish("AAA\n", AFTER, nil, ipos: ipos, paste_lines: true)
|
|
134
|
+
assert_buf "AAA\nAAA\nBBB\nCCC\n\n"
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Without a captured position (synchronous/macro path) the live cursor is
|
|
138
|
+
# used, preserving prior behavior.
|
|
139
|
+
def test_paste_finish_without_capture_uses_live_cursor
|
|
140
|
+
act 'buf.insert_txt("line one\nline two\n")'
|
|
141
|
+
act "move.buf.start"
|
|
142
|
+
vma.clipboard << "X"
|
|
143
|
+
buf.paste_finish("X", AFTER, nil)
|
|
144
|
+
assert_buf "lXine one\nline two\n\n"
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# --- Copy to mark (y'a) ----------------------------------------------------
|
|
148
|
+
# copy(:to_mark) yanks the same range delete2(:to_mark) removes: from the end
|
|
149
|
+
# of the current line to the mark position.
|
|
150
|
+
def test_copy_to_mark
|
|
151
|
+
act 'buf.insert_txt("AAA\nBBB\nCCC\n")'
|
|
152
|
+
act "buf.set_pos(8)" # start of "CCC"
|
|
153
|
+
act "buf.mark_current_position('a')"
|
|
154
|
+
act "move.buf.start" # cursor back on line 0
|
|
155
|
+
act "buf.copy(:to_mark, 'a')"
|
|
156
|
+
assert_eq "\nBBB\nC", vma.clipboard.get
|
|
157
|
+
assert_buf "AAA\nBBB\nCCC\n\n" # buffer unchanged by a copy
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def test_copy_to_undefined_mark_is_noop
|
|
161
|
+
act 'buf.insert_txt("hello")'
|
|
162
|
+
vma.clipboard.set("PREVIOUS")
|
|
163
|
+
act "buf.copy(:to_mark, 'z')" # mark 'z' was never set
|
|
164
|
+
assert_eq "PREVIOUS", vma.clipboard.get # clipboard untouched
|
|
165
|
+
assert_buf "hello\n"
|
|
166
|
+
end
|
|
167
|
+
|
|
88
168
|
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
class TestCrashHandler < VmaTest
|
|
2
|
+
|
|
3
|
+
# report() writes a .txt and .json into the crash dir, then we clean up.
|
|
4
|
+
def test_report_writes_files
|
|
5
|
+
base = Vimamsa::CrashHandler.report("test", RuntimeError.new("kaboom"))
|
|
6
|
+
assert !base.nil?, "report should return a base path"
|
|
7
|
+
txt = "#{base}.txt"
|
|
8
|
+
json = "#{base}.json"
|
|
9
|
+
assert File.exist?(txt), "crash .txt should be written"
|
|
10
|
+
assert File.exist?(json), "crash .json should be written"
|
|
11
|
+
body = File.read(txt)
|
|
12
|
+
assert body.include?("RuntimeError: kaboom"), "exception line present"
|
|
13
|
+
assert body.include?("--- backtrace ---")
|
|
14
|
+
assert body.include?("--- current buffer ---")
|
|
15
|
+
ensure
|
|
16
|
+
File.delete(txt) if txt && File.exist?(txt)
|
|
17
|
+
File.delete(json) if json && File.exist?(json)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Each snapshot field is collected independently; a raising collector must
|
|
21
|
+
# not abort the report — it records a placeholder instead.
|
|
22
|
+
def test_add_degrades_gracefully
|
|
23
|
+
info = {}
|
|
24
|
+
Vimamsa::CrashHandler.add(info, "boom") { raise "nope" }
|
|
25
|
+
assert info["boom"].to_s.start_with?("<unavailable"), info["boom"].inspect
|
|
26
|
+
Vimamsa::CrashHandler.add(info, "ok") { 42 }
|
|
27
|
+
assert_eq 42, info["ok"]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# The report captures live editor state (current buffer contents).
|
|
31
|
+
def test_report_includes_buffer_state
|
|
32
|
+
vma.buf.set_content("crashy #ff0000 buffer\n")
|
|
33
|
+
base = Vimamsa::CrashHandler.report("test")
|
|
34
|
+
body = File.read("#{base}.txt")
|
|
35
|
+
assert body.include?("crashy #ff0000 buffer"), "buffer head should be captured"
|
|
36
|
+
ensure
|
|
37
|
+
["#{base}.txt", "#{base}.json"].each { |f| File.delete(f) if base && File.exist?(f) }
|
|
38
|
+
end
|
|
39
|
+
end
|