vimamsa 0.1.26 → 0.1.27
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 +62 -16
- data/custom_example.rb +43 -13
- data/doc/TODO.md +461 -0
- data/doc/bundling_plan.md +569 -0
- data/doc/key_bindings_report_plan.md +168 -0
- data/doc/missing_vim_bindings.md +71 -0
- data/doc/modules_settings_plan.md +433 -0
- data/doc/refactor_dedup_plan.md +117 -0
- data/doc/unused_code_plan.md +120 -0
- data/doc/vim_compatibility_plan.md +296 -0
- data/doc/vimlike_vim_conflicts.md +254 -0
- data/doc/vm_snapshots_plan.md +146 -0
- data/exe/run_tests.rb +117 -3
- data/exe/vimamsa +24 -4
- data/fonts/OFL-Oxanium.txt +93 -0
- data/fonts/Oxanium[wght].ttf +0 -0
- data/icon.png +0 -0
- data/img/demo.gif +0 -0
- data/lang/hyperplaintext.lang +6 -0
- data/lib/vimamsa/ack.rb +11 -1
- data/lib/vimamsa/actions.rb +4 -1
- 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 +593 -82
- data/lib/vimamsa/buffer_changetext.rb +102 -42
- data/lib/vimamsa/buffer_cursor.rb +7 -0
- data/lib/vimamsa/buffer_list.rb +4 -0
- data/lib/vimamsa/buffer_manager.rb +4 -1
- data/lib/vimamsa/bundled_fonts.rb +32 -0
- data/lib/vimamsa/clipboard.rb +3 -0
- data/lib/vimamsa/conf.rb +59 -3
- data/lib/vimamsa/constants.rb +3 -0
- data/lib/vimamsa/crash_handler.rb +149 -0
- data/lib/vimamsa/debug.rb +4 -1
- data/lib/vimamsa/desktop_install.rb +96 -0
- data/lib/vimamsa/diff_buffer.rb +39 -10
- data/lib/vimamsa/easy_jump.rb +3 -0
- data/lib/vimamsa/editor.rb +263 -57
- data/lib/vimamsa/encrypt.rb +78 -29
- data/lib/vimamsa/file_finder.rb +4 -19
- data/lib/vimamsa/file_history.rb +3 -0
- data/lib/vimamsa/file_manager.rb +30 -15
- data/lib/vimamsa/fold.rb +226 -0
- data/lib/vimamsa/gui.rb +520 -106
- data/lib/vimamsa/gui_command_line.rb +208 -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 +59 -35
- data/lib/vimamsa/gui_func_panel.rb +67 -22
- data/lib/vimamsa/gui_image.rb +3 -0
- data/lib/vimamsa/gui_keylog_panel.rb +246 -0
- data/lib/vimamsa/gui_menu.rb +23 -11
- data/lib/vimamsa/gui_select_window.rb +19 -48
- data/lib/vimamsa/gui_settings.rb +78 -37
- data/lib/vimamsa/gui_sourceview.rb +273 -19
- data/lib/vimamsa/gui_sourceview_autocomplete.rb +319 -90
- data/lib/vimamsa/gui_text.rb +63 -2
- data/lib/vimamsa/gui_theme.rb +606 -0
- data/lib/vimamsa/hook.rb +3 -0
- data/lib/vimamsa/hyper_plain_text.rb +3 -0
- data/lib/vimamsa/key_actions.rb +112 -13
- data/lib/vimamsa/key_binding_tree.rb +242 -215
- data/lib/vimamsa/key_bindings_notepad.rb +43 -0
- data/lib/vimamsa/key_bindings_report.rb +261 -0
- data/lib/vimamsa/key_bindings_vim.rb +354 -0
- data/lib/vimamsa/key_bindings_vimlike.rb +65 -9
- data/lib/vimamsa/langservp.rb +271 -54
- data/lib/vimamsa/macro.rb +3 -0
- data/lib/vimamsa/main.rb +14 -8
- data/lib/vimamsa/rbvma.rb +26 -1
- data/lib/vimamsa/search.rb +3 -0
- data/lib/vimamsa/search_replace.rb +11 -10
- data/lib/vimamsa/string_util.rb +120 -40
- data/lib/vimamsa/terminal.rb +3 -0
- data/lib/vimamsa/test_framework.rb +28 -2
- data/lib/vimamsa/tests.rb +3 -0
- data/lib/vimamsa/text_objects.rb +353 -0
- data/lib/vimamsa/text_transforms.rb +14 -0
- data/lib/vimamsa/util.rb +46 -7
- data/lib/vimamsa/version.rb +1 -1
- data/lib/vimamsa.rb +0 -1
- 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/tts/tts.rb +119 -0
- data/modules/tts/tts_info.rb +3 -0
- data/run_e2e_vm.sh +28 -0
- data/run_tests_vm.sh +130 -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_steps.txt +59 -0
- data/scripts/demo/record_demo.rb +177 -0
- data/scripts/demo/shapes.rb +28 -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_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 +33 -3
- data/tests/test_bookmarks.rb +206 -0
- data/tests/test_bracket_match.rb +85 -0
- data/tests/test_bundling.rb +92 -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 +129 -0
- data/tests/test_copy_paste.rb +80 -0
- data/tests/test_crash_handler.rb +39 -0
- data/tests/test_custom_two_phase.rb +92 -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_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_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_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_jump_to_file.rb +41 -0
- data/tests/test_key_bindings.rb +208 -0
- data/tests/test_keylog_panel.rb +101 -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_notepad_bindings.rb +67 -0
- data/tests/test_popup_queue.rb +51 -0
- data/tests/test_random_edit.rb +109 -0
- data/tests/test_revert.rb +127 -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 +329 -0
- data/tests/test_tts.rb +68 -0
- data/tests/test_vim_bindings.rb +252 -0
- data/tests/test_vim_conflicts.rb +63 -0
- data/tests/test_window_layout.rb +219 -0
- data/vimamsa.gemspec +3 -1
- data/vm_guest_run.sh +109 -0
- metadata +112 -10
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
require "tmpdir"
|
|
2
|
+
require "fileutils"
|
|
3
|
+
|
|
4
|
+
# Covers Buffer#check_autosave_load's decision to prompt vs. silently drop an
|
|
5
|
+
# autosave file (.<name>_vma_autosave) when a file is opened:
|
|
6
|
+
# - autosave identical to the file -> deleted, no prompt
|
|
7
|
+
# - autosave older than the file (stale) -> deleted, no prompt (the fix)
|
|
8
|
+
# - autosave newer than the file -> kept, prompt shown
|
|
9
|
+
#
|
|
10
|
+
# The prompt is a GTK popup; for the "newer" case we stub PopupFormGenerator#run
|
|
11
|
+
# so the test neither blocks nor leaves a window behind, and record whether it
|
|
12
|
+
# would have been shown.
|
|
13
|
+
|
|
14
|
+
class TestAutosave < VmaTest
|
|
15
|
+
# Build a buffer backed by a real temp file, plus an autosave file next to it.
|
|
16
|
+
# Returns [buffer, file_path, autosave_path]. Caller sets mtimes as needed.
|
|
17
|
+
def make_backed_buffer(file_content, autosave_content)
|
|
18
|
+
dir = Dir.mktmpdir("vma_autosave_test")
|
|
19
|
+
@tmpdirs << dir
|
|
20
|
+
path = File.join(dir, "note.txt")
|
|
21
|
+
File.write(path, file_content)
|
|
22
|
+
b = create_new_buffer(file_content, "test", true)
|
|
23
|
+
b.set_filename(path)
|
|
24
|
+
apath = b.autosave_path
|
|
25
|
+
File.write(apath, autosave_content)
|
|
26
|
+
[b, path, apath]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def set_older(apath, path)
|
|
30
|
+
now = Time.now
|
|
31
|
+
File.utime(now - 100, now - 100, apath) # autosave older
|
|
32
|
+
File.utime(now, now, path) # file newer
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def set_newer(apath, path)
|
|
36
|
+
now = Time.now
|
|
37
|
+
File.utime(now, now, apath) # autosave newer
|
|
38
|
+
File.utime(now - 100, now - 100, path) # file older
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Run block with PopupFormGenerator#run stubbed out; returns true if a popup
|
|
42
|
+
# would have been shown.
|
|
43
|
+
def popup_shown_during
|
|
44
|
+
$vma_test_popup_shown = false
|
|
45
|
+
orig = PopupFormGenerator.instance_method(:run)
|
|
46
|
+
PopupFormGenerator.send(:define_method, :run) { |*_a| $vma_test_popup_shown = true; self }
|
|
47
|
+
yield
|
|
48
|
+
$vma_test_popup_shown
|
|
49
|
+
ensure
|
|
50
|
+
PopupFormGenerator.send(:define_method, :run, orig)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def setup_dirs
|
|
54
|
+
@tmpdirs ||= []
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def cleanup_dirs
|
|
58
|
+
(@tmpdirs || []).each { |d| FileUtils.remove_entry(d, true) }
|
|
59
|
+
@tmpdirs = []
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_stale_autosave_deleted_silently
|
|
63
|
+
setup_dirs
|
|
64
|
+
b, path, apath = make_backed_buffer("current on disk\n", "stale autosave contents\n")
|
|
65
|
+
set_older(apath, path)
|
|
66
|
+
shown = popup_shown_during { b.check_autosave_load }
|
|
67
|
+
assert(!File.exist?(apath), "stale autosave should be deleted")
|
|
68
|
+
assert(!shown, "no prompt should be shown for a stale autosave")
|
|
69
|
+
ensure
|
|
70
|
+
cleanup_dirs
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_identical_autosave_deleted_silently
|
|
74
|
+
setup_dirs
|
|
75
|
+
b, path, apath = make_backed_buffer("hello world\n", "hello world\n")
|
|
76
|
+
# mtimes irrelevant here; identical content is dropped regardless.
|
|
77
|
+
set_newer(apath, path)
|
|
78
|
+
shown = popup_shown_during { b.check_autosave_load }
|
|
79
|
+
assert(!File.exist?(apath), "autosave identical to file should be deleted")
|
|
80
|
+
assert(!shown, "no prompt should be shown when autosave equals the file")
|
|
81
|
+
ensure
|
|
82
|
+
cleanup_dirs
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_newer_autosave_kept_and_prompts
|
|
86
|
+
setup_dirs
|
|
87
|
+
b, path, apath = make_backed_buffer("saved version\n", "newer unsaved edits\n")
|
|
88
|
+
set_newer(apath, path)
|
|
89
|
+
shown = popup_shown_during { b.check_autosave_load }
|
|
90
|
+
assert(File.exist?(apath), "a newer autosave must not be deleted")
|
|
91
|
+
assert(shown, "a newer, differing autosave should prompt")
|
|
92
|
+
ensure
|
|
93
|
+
cleanup_dirs
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# ── Deferred check for session-restored buffers ──────────────────────────
|
|
97
|
+
# Session restore loads buffers without running check_autosave_load; the
|
|
98
|
+
# check is deferred (needs_autosave_check) until the buffer is first entered
|
|
99
|
+
# via set_current_buffer.
|
|
100
|
+
|
|
101
|
+
# Enter another buffer, then switch (back) to `b` — the "enter buffer" path.
|
|
102
|
+
def enter_buffer(b)
|
|
103
|
+
create_new_buffer("\n", "decoy", true) # move current buffer away from b
|
|
104
|
+
vma.buffers.set_current_buffer_by_id(b.id)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def test_restored_newer_autosave_prompts_on_enter
|
|
108
|
+
setup_dirs
|
|
109
|
+
b, path, apath = make_backed_buffer("saved version\n", "newer unsaved edits\n")
|
|
110
|
+
set_newer(apath, path)
|
|
111
|
+
b.needs_autosave_check = true
|
|
112
|
+
shown = popup_shown_during { enter_buffer(b) }
|
|
113
|
+
assert(shown, "restored buffer should prompt when first entered")
|
|
114
|
+
assert(File.exist?(apath), "newer autosave must be kept")
|
|
115
|
+
assert(!b.needs_autosave_check, "pending flag should be cleared after entering")
|
|
116
|
+
ensure
|
|
117
|
+
cleanup_dirs
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def test_restored_stale_autosave_deleted_on_enter
|
|
121
|
+
setup_dirs
|
|
122
|
+
b, path, apath = make_backed_buffer("current on disk\n", "stale autosave\n")
|
|
123
|
+
set_older(apath, path)
|
|
124
|
+
b.needs_autosave_check = true
|
|
125
|
+
shown = popup_shown_during { enter_buffer(b) }
|
|
126
|
+
assert(!shown, "stale autosave should not prompt on enter")
|
|
127
|
+
assert(!File.exist?(apath), "stale autosave should be deleted on enter")
|
|
128
|
+
assert(!b.needs_autosave_check, "pending flag should be cleared after entering")
|
|
129
|
+
ensure
|
|
130
|
+
cleanup_dirs
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def test_unflagged_buffer_not_checked_on_enter
|
|
134
|
+
setup_dirs
|
|
135
|
+
# No needs_autosave_check flag (a normal, non-restored buffer): entering it
|
|
136
|
+
# must not run the autosave check, even with a newer differing autosave.
|
|
137
|
+
b, path, apath = make_backed_buffer("saved version\n", "newer unsaved edits\n")
|
|
138
|
+
set_newer(apath, path)
|
|
139
|
+
shown = popup_shown_during { enter_buffer(b) }
|
|
140
|
+
assert(!shown, "unflagged buffer must not prompt on enter")
|
|
141
|
+
assert(File.exist?(apath), "unflagged buffer must not touch the autosave")
|
|
142
|
+
ensure
|
|
143
|
+
cleanup_dirs
|
|
144
|
+
end
|
|
145
|
+
end
|
data/tests/test_basic_editing.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
class TestBasicEditing < VmaTest
|
|
2
|
-
|
|
3
2
|
def test_insert_text
|
|
4
3
|
act 'buf.insert_txt("hello")'
|
|
5
4
|
assert_buf "hello\n"
|
|
@@ -20,6 +19,16 @@ class TestBasicEditing < VmaTest
|
|
|
20
19
|
assert_buf "abc\n"
|
|
21
20
|
end
|
|
22
21
|
|
|
22
|
+
def test_select_all_action
|
|
23
|
+
act 'buf.insert_txt("hello\nworld")'
|
|
24
|
+
act :select_all
|
|
25
|
+
assert vma.buf.selection_active?, "select_all should activate selection"
|
|
26
|
+
assert_eq 0, vma.buf.get_visual_mode_range.begin
|
|
27
|
+
assert_eq vma.buf.size - 1, vma.buf.get_visual_mode_range.end
|
|
28
|
+
act :copy_selection
|
|
29
|
+
assert_eq "hello\nworld\n", vma.clipboard.get
|
|
30
|
+
end
|
|
31
|
+
|
|
23
32
|
def test_undo_redo
|
|
24
33
|
act 'buf.insert_txt("hello")'
|
|
25
34
|
assert_buf "hello\n"
|
|
@@ -61,11 +70,9 @@ class TestBasicEditing < VmaTest
|
|
|
61
70
|
act :delete_line
|
|
62
71
|
assert_buf "second\n"
|
|
63
72
|
end
|
|
64
|
-
|
|
65
73
|
end
|
|
66
74
|
|
|
67
75
|
class TestKeySequences < VmaTest
|
|
68
|
-
|
|
69
76
|
def test_insert_mode_via_keys
|
|
70
77
|
# 'i' enters insert mode in command mode
|
|
71
78
|
keys "i"
|
|
@@ -82,5 +89,28 @@ class TestKeySequences < VmaTest
|
|
|
82
89
|
assert_buf "hello\n"
|
|
83
90
|
assert_mode :command
|
|
84
91
|
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
class TestDeleteFindChar < VmaTest
|
|
95
|
+
def test_df_char
|
|
96
|
+
act 'buf.insert_txt("foo bar baz")'
|
|
97
|
+
act :jump_to_start_of_buffer
|
|
98
|
+
keys "d f a"
|
|
99
|
+
assert_buf "r baz\n"
|
|
100
|
+
end
|
|
85
101
|
|
|
102
|
+
def test_dF_char
|
|
103
|
+
act 'buf.insert_txt("foo bar baz")'
|
|
104
|
+
act :jump_to_start_of_buffer
|
|
105
|
+
act "buf.set_pos(10)" # on the final 'z'
|
|
106
|
+
keys "d F a"
|
|
107
|
+
assert_buf "foo bar bz\n"
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_df_not_on_line_is_noop
|
|
111
|
+
act 'buf.insert_txt("foo\nbar")'
|
|
112
|
+
act :jump_to_start_of_buffer
|
|
113
|
+
keys "d f b"
|
|
114
|
+
assert_buf "foo\nbar\n"
|
|
115
|
+
end
|
|
86
116
|
end
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
require "tempfile"
|
|
2
|
+
|
|
3
|
+
# Persistent bookmarks (lib/vimamsa/bookmarks.rb): , M to add, , ' to list.
|
|
4
|
+
class TestBookmarks < VmaTest
|
|
5
|
+
SAMPLE = (1..10).collect { |i| "line #{i}\n" }.join # "line 1" .. "line 10"
|
|
6
|
+
|
|
7
|
+
def make_file(contents)
|
|
8
|
+
f = Tempfile.new(["bookmark_target", ".txt"])
|
|
9
|
+
f.write(contents)
|
|
10
|
+
f.flush
|
|
11
|
+
f
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def cleanup(f)
|
|
15
|
+
path = File.expand_path(f.path)
|
|
16
|
+
vma.bookmarks.list.select { |bm| bm[:fname] == path }.each { |bm| vma.bookmarks.delete(bm) }
|
|
17
|
+
close_file(path)
|
|
18
|
+
f.close
|
|
19
|
+
f.unlink
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def close_file(path)
|
|
23
|
+
id = vma.buffers.get_buffer_by_filename(path)
|
|
24
|
+
vma.buffers.close_buffer(id) if id
|
|
25
|
+
drain_idle
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# lpos is 0-based
|
|
29
|
+
def add_at(path, lpos)
|
|
30
|
+
jump_to_file(path, lpos + 1)
|
|
31
|
+
assert_eq lpos, vma.buf.lpos
|
|
32
|
+
act(:bookmark_add)
|
|
33
|
+
bm = vma.bookmarks.list.find { |b| b[:fname] == path && b[:lpos] == lpos }
|
|
34
|
+
assert bm, "bookmark was not added at line #{lpos}"
|
|
35
|
+
bm
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_add_and_jump
|
|
39
|
+
f = make_file(SAMPLE)
|
|
40
|
+
path = File.expand_path(f.path)
|
|
41
|
+
bm = add_at(path, 4)
|
|
42
|
+
assert_eq "line 5", bm[:text]
|
|
43
|
+
assert_eq "line 4", bm[:before]
|
|
44
|
+
assert_eq "line 6", bm[:after]
|
|
45
|
+
|
|
46
|
+
create_new_buffer("\n", "other", true)
|
|
47
|
+
assert vma.bookmarks.jump(bm), "jump failed"
|
|
48
|
+
assert_eq path, vma.buf.fname
|
|
49
|
+
assert_eq 4, vma.buf.lpos
|
|
50
|
+
ensure
|
|
51
|
+
cleanup(f)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_keys_add_bookmark
|
|
55
|
+
f = make_file(SAMPLE)
|
|
56
|
+
path = File.expand_path(f.path)
|
|
57
|
+
jump_to_file(path, 3)
|
|
58
|
+
keys(", M")
|
|
59
|
+
bm = vma.bookmarks.list.find { |b| b[:fname] == path }
|
|
60
|
+
assert bm, ", M did not add a bookmark"
|
|
61
|
+
assert_eq 2, bm[:lpos]
|
|
62
|
+
ensure
|
|
63
|
+
cleanup(f)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_same_line_replaces
|
|
67
|
+
f = make_file(SAMPLE)
|
|
68
|
+
path = File.expand_path(f.path)
|
|
69
|
+
add_at(path, 4)
|
|
70
|
+
add_at(path, 4)
|
|
71
|
+
assert_eq 1, vma.bookmarks.list.count { |b| b[:fname] == path }
|
|
72
|
+
ensure
|
|
73
|
+
cleanup(f)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# File changed outside the editor: the line moved, found again by its text
|
|
77
|
+
def test_regexp_recovery_after_external_change
|
|
78
|
+
f = make_file(SAMPLE)
|
|
79
|
+
path = File.expand_path(f.path)
|
|
80
|
+
bm = add_at(path, 4)
|
|
81
|
+
close_file(path)
|
|
82
|
+
File.write(path, "new a\nnew b\nnew c\n" + SAMPLE)
|
|
83
|
+
|
|
84
|
+
assert vma.bookmarks.jump(bm), "jump failed"
|
|
85
|
+
assert_eq 7, vma.buf.lpos
|
|
86
|
+
assert_eq 7, bm[:lpos], "stored line should be updated after jump"
|
|
87
|
+
ensure
|
|
88
|
+
cleanup(f)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_whitespace_changes_still_match
|
|
92
|
+
f = make_file("a\nfoo(x, y)\nb\n")
|
|
93
|
+
path = File.expand_path(f.path)
|
|
94
|
+
bm = add_at(path, 1)
|
|
95
|
+
close_file(path)
|
|
96
|
+
File.write(path, "z\nz\na\n foo(x, y)\nb\n")
|
|
97
|
+
|
|
98
|
+
vma.bookmarks.jump(bm)
|
|
99
|
+
assert_eq 3, vma.buf.lpos
|
|
100
|
+
ensure
|
|
101
|
+
cleanup(f)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Two identical lines: the one with matching context wins even when the
|
|
105
|
+
# other one is at the stored line number.
|
|
106
|
+
def test_duplicate_lines_use_context
|
|
107
|
+
f = make_file("def a\n x = 1\nend\ndef b\n y = 2\nend\n")
|
|
108
|
+
path = File.expand_path(f.path)
|
|
109
|
+
bm = add_at(path, 5) # "end" after "y = 2"
|
|
110
|
+
close_file(path)
|
|
111
|
+
File.write(path, "def b\n y = 2\nend\ndef a\n x = 1\nend\n")
|
|
112
|
+
|
|
113
|
+
vma.bookmarks.jump(bm)
|
|
114
|
+
assert_eq 2, vma.buf.lpos
|
|
115
|
+
ensure
|
|
116
|
+
cleanup(f)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def test_text_deleted_falls_back_to_line_number
|
|
120
|
+
f = make_file(SAMPLE)
|
|
121
|
+
path = File.expand_path(f.path)
|
|
122
|
+
bm = add_at(path, 8)
|
|
123
|
+
close_file(path)
|
|
124
|
+
File.write(path, "a\nb\nc\n")
|
|
125
|
+
|
|
126
|
+
assert vma.bookmarks.jump(bm), "jump failed"
|
|
127
|
+
assert_eq 2, vma.buf.lpos # clamped to last line
|
|
128
|
+
assert_eq "line 9", bm[:text], "stored text must not be overwritten"
|
|
129
|
+
ensure
|
|
130
|
+
cleanup(f)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def test_persisted_to_disk
|
|
134
|
+
f = make_file(SAMPLE)
|
|
135
|
+
path = File.expand_path(f.path)
|
|
136
|
+
bm = add_at(path, 2)
|
|
137
|
+
stored = vma.marshal_load("bookmarks", [])
|
|
138
|
+
assert stored.any? { |b| b[:fname] == path && b[:text] == "line 3" }, "bookmark not saved to disk"
|
|
139
|
+
|
|
140
|
+
vma.bookmarks.delete(bm)
|
|
141
|
+
stored = vma.marshal_load("bookmarks", [])
|
|
142
|
+
assert !stored.any? { |b| b[:fname] == path }, "deleted bookmark still on disk"
|
|
143
|
+
ensure
|
|
144
|
+
cleanup(f)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Edits in an open buffer move the bookmark; saving stores the new line.
|
|
148
|
+
def test_tracked_while_open_and_saved
|
|
149
|
+
f = make_file(SAMPLE)
|
|
150
|
+
path = File.expand_path(f.path)
|
|
151
|
+
bm = add_at(path, 4)
|
|
152
|
+
vma.buf.set_pos(0)
|
|
153
|
+
act('buf.insert_txt("new1\nnew2\n")')
|
|
154
|
+
vma.buf.save
|
|
155
|
+
drain_idle
|
|
156
|
+
|
|
157
|
+
assert_eq 6, bm[:lpos]
|
|
158
|
+
assert_eq "line 5", bm[:text]
|
|
159
|
+
assert_eq "line 4", bm[:before]
|
|
160
|
+
assert File.read(path).start_with?("new1\nnew2\n"), "file was not saved"
|
|
161
|
+
ensure
|
|
162
|
+
cleanup(f)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def test_list_newest_first_and_select
|
|
166
|
+
f = make_file(SAMPLE)
|
|
167
|
+
path = File.expand_path(f.path)
|
|
168
|
+
b1 = add_at(path, 0)
|
|
169
|
+
b3 = add_at(path, 2)
|
|
170
|
+
b5 = add_at(path, 4)
|
|
171
|
+
b1[:created] = Time.now - 300
|
|
172
|
+
b3[:created] = Time.now - 200
|
|
173
|
+
b5[:created] = Time.now - 100
|
|
174
|
+
|
|
175
|
+
act(:bookmark_list)
|
|
176
|
+
assert_mode :bmark
|
|
177
|
+
list_id = vma.buf.id
|
|
178
|
+
rows = vma.buf.to_s.lines.select { |l| l.include?(tilde_path(path)) }.collect(&:strip)
|
|
179
|
+
assert_eq ["line 5", "line 3", "line 1"], rows.collect { |r| r.split(" ").last }
|
|
180
|
+
|
|
181
|
+
act(:bmark_select) # cursor starts on the first (newest) row
|
|
182
|
+
assert_eq path, vma.buf.fname
|
|
183
|
+
assert_eq 4, vma.buf.lpos
|
|
184
|
+
assert vma.buffers.get_buffer_by_id(list_id).nil?, "list buffer should be closed"
|
|
185
|
+
assert_mode vma.kbd.default_mode
|
|
186
|
+
ensure
|
|
187
|
+
cleanup(f)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def test_list_delete
|
|
191
|
+
f = make_file(SAMPLE)
|
|
192
|
+
path = File.expand_path(f.path)
|
|
193
|
+
add_at(path, 1)
|
|
194
|
+
bm = add_at(path, 6) # newest -> first row
|
|
195
|
+
|
|
196
|
+
act(:bookmark_list)
|
|
197
|
+
act(:bmark_delete)
|
|
198
|
+
assert !vma.bookmarks.list.include?(bm), "bookmark not deleted"
|
|
199
|
+
assert_eq 1, vma.bookmarks.list.count { |b| b[:fname] == path }
|
|
200
|
+
rows = vma.buf.to_s.lines.select { |l| l.include?(tilde_path(path)) }
|
|
201
|
+
assert_eq 1, rows.size
|
|
202
|
+
act(:close_current_buffer)
|
|
203
|
+
ensure
|
|
204
|
+
cleanup(f)
|
|
205
|
+
end
|
|
206
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# With the cursor on a bracket, GtkSourceView highlights its matching bracket
|
|
2
|
+
# (buffer.highlight_matching_brackets, set in gui_create_buffer, styled by the
|
|
3
|
+
# scheme's "bracket-match" style).
|
|
4
|
+
class TestBracketMatch < VmaTest
|
|
5
|
+
TEXT = "foo(bar[1], {a: 2}) x\n"
|
|
6
|
+
|
|
7
|
+
# GtkSourceView updates the bracket highlight from a low-priority main loop
|
|
8
|
+
# source, so give the loop real time rather than a fixed iteration count.
|
|
9
|
+
def wait_main_loop(sec = 0.3)
|
|
10
|
+
t = Time.now
|
|
11
|
+
GLib::MainContext.default.iteration(false) while Time.now - t < sec
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Put text in the current buffer, move the cursor to pos and return
|
|
15
|
+
# [matched_offset, state] from the last "bracket-matched" signal, state as
|
|
16
|
+
# :found, :not_found, :out_of_range or :none. nil if no signal came.
|
|
17
|
+
def match_at(pos, text = TEXT)
|
|
18
|
+
b = vma.buf
|
|
19
|
+
b.set_content(text)
|
|
20
|
+
drain_idle
|
|
21
|
+
gbuf = b.view.buffer
|
|
22
|
+
# Start from a non-bracket position so moving to pos is a real change
|
|
23
|
+
b.set_pos(text.index(" ") || 0)
|
|
24
|
+
wait_main_loop
|
|
25
|
+
got = nil
|
|
26
|
+
hid = gbuf.signal_connect("bracket-matched") do |_buf, iter, state|
|
|
27
|
+
got = [state.nick.tr("-", "_").to_sym == :found ? iter.offset : nil, state.nick.tr("-", "_").to_sym]
|
|
28
|
+
end
|
|
29
|
+
begin
|
|
30
|
+
b.set_pos(pos)
|
|
31
|
+
wait_main_loop
|
|
32
|
+
ensure
|
|
33
|
+
gbuf.signal_handler_disconnect(hid)
|
|
34
|
+
end
|
|
35
|
+
got
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Tags at offset that paint a background (the bracket-match highlight)
|
|
39
|
+
def highlight_tags_at(offset)
|
|
40
|
+
gbuf = vma.buf.view.buffer
|
|
41
|
+
gbuf.get_iter_at(:offset => offset).tags.select { |t| t.background_set? }
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_enabled_on_gtk_buffer
|
|
45
|
+
assert vma.buf.view.buffer.highlight_matching_brackets?, "highlight_matching_brackets is off"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_scheme_defines_bracket_match_style
|
|
49
|
+
sty = vma.buf.view.buffer.style_scheme
|
|
50
|
+
assert !sty.nil?, "no style scheme"
|
|
51
|
+
assert !sty.get_style("bracket-match").nil?, "scheme #{sty.id} has no bracket-match style"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_open_paren_matches_close
|
|
55
|
+
assert_eq [TEXT.index(")"), :found], match_at(TEXT.index("("))
|
|
56
|
+
assert !highlight_tags_at(TEXT.index(")")).empty?, "closing ) not highlighted"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_close_paren_matches_open
|
|
60
|
+
assert_eq [TEXT.index("("), :found], match_at(TEXT.index(")"))
|
|
61
|
+
assert !highlight_tags_at(TEXT.index("(")).empty?, "opening ( not highlighted"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_square_and_curly
|
|
65
|
+
assert_eq [TEXT.index("]"), :found], match_at(TEXT.index("["))
|
|
66
|
+
assert_eq [TEXT.index("}"), :found], match_at(TEXT.index("{"))
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_nested_matches_outer
|
|
70
|
+
t = "((a)(b)) z\n"
|
|
71
|
+
assert_eq [7, :found], match_at(0, t)
|
|
72
|
+
assert_eq [3, :found], match_at(1, t)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def test_unbalanced_is_not_found
|
|
76
|
+
assert_eq [nil, :not_found], match_at(0, "(abc def\n")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_highlight_cleared_when_cursor_leaves
|
|
80
|
+
assert_eq [TEXT.index(")"), :found], match_at(TEXT.index("("))
|
|
81
|
+
vma.buf.set_pos(TEXT.index("x"))
|
|
82
|
+
wait_main_loop
|
|
83
|
+
assert highlight_tags_at(TEXT.index(")")).empty?, ") still highlighted with cursor away"
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
require "tmpdir"
|
|
2
|
+
require "open3"
|
|
3
|
+
|
|
4
|
+
# Code changes for running from a bundle (doc/bundling_plan.md, "Code changes
|
|
5
|
+
# needed regardless of format").
|
|
6
|
+
class TestBundling < VmaTest
|
|
7
|
+
def with_env(name, val)
|
|
8
|
+
old = ENV[name]
|
|
9
|
+
ENV[name] = val
|
|
10
|
+
yield
|
|
11
|
+
ensure
|
|
12
|
+
ENV[name] = old
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_launcher_runs_gem_binstub_by_default
|
|
16
|
+
with_env("APPIMAGE", nil) {
|
|
17
|
+
assert_eq "vimamsa %F", desktop_exec_command
|
|
18
|
+
assert desktop_entry_contents.include?("\nExec=vimamsa %F\n")
|
|
19
|
+
}
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_launcher_runs_the_appimage
|
|
23
|
+
with_env("APPIMAGE", "/home/u/Apps/Vimamsa-x86_64.AppImage") {
|
|
24
|
+
assert_eq %{"/home/u/Apps/Vimamsa-x86_64.AppImage" %F}, desktop_exec_command
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_launcher_quotes_odd_appimage_paths
|
|
29
|
+
# Spaces stay inside the quotes; " ` $ \ are escaped, % is doubled
|
|
30
|
+
with_env("APPIMAGE", %{/home/u/My Apps/a"b$c%d\\e.AppImage}) {
|
|
31
|
+
assert_eq %{"/home/u/My Apps/a\\\\"b\\\\$c%%d\\\\\\\\e.AppImage" %F}, desktop_exec_command
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# exe/vimamsa must load lib/ next to itself, not ./lib of the current dir
|
|
36
|
+
def test_exe_load_path_is_relative_to_script
|
|
37
|
+
exe = File.expand_path("../exe/vimamsa", __dir__)
|
|
38
|
+
src = File.read(exe)
|
|
39
|
+
assert !src.include?('File.expand_path("lib")'), "exe/vimamsa uses ./lib of the current directory"
|
|
40
|
+
Dir.mktmpdir { |dir|
|
|
41
|
+
# A decoy lib/vimamsa.rb in the current directory must not be loaded
|
|
42
|
+
Dir.mkdir("#{dir}/lib")
|
|
43
|
+
File.write("#{dir}/lib/vimamsa.rb", "puts 'DECOY'; exit 3\n")
|
|
44
|
+
code = src[/\A.*?\$LOAD_PATH\.unshift\(File\.join\(scriptdir, "ext"\)\)\n/m]
|
|
45
|
+
assert code, "load path lines not found in exe/vimamsa"
|
|
46
|
+
code = code.sub(/^require "ripl\/multi_line"\n/, "")
|
|
47
|
+
script = "#{dir}/probe.rb"
|
|
48
|
+
File.write(script, code.sub("selfpath = __FILE__", "selfpath = #{exe.inspect}") +
|
|
49
|
+
"puts $LOAD_PATH.first(2)\n")
|
|
50
|
+
out, st = Open3.capture2e(RbConfig.ruby, script, chdir: dir)
|
|
51
|
+
assert st.success?, out
|
|
52
|
+
root = File.expand_path("..", __dir__)
|
|
53
|
+
assert_eq ["#{root}/ext", "#{root}/lib"], out.split("\n").last(2)
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# ── restore_host_env (lib/vimamsa/appimage_env.rb) ──
|
|
58
|
+
|
|
59
|
+
def test_restore_host_env_puts_back_previous_values
|
|
60
|
+
saved = ENV.to_h
|
|
61
|
+
ENV["VMA_APPIMAGE_ENV"] = " VMA_T_SET VMA_T_UNSET"
|
|
62
|
+
ENV["VMA_HOST_VMA_T_SET"] = "host value"
|
|
63
|
+
ENV["VMA_T_SET"] = "bundle value"
|
|
64
|
+
ENV["VMA_T_UNSET"] = "bundle value"
|
|
65
|
+
restore_host_env
|
|
66
|
+
assert_eq "host value", ENV["VMA_T_SET"]
|
|
67
|
+
assert !ENV.key?("VMA_T_UNSET"), "a variable the host didn't have must be removed"
|
|
68
|
+
assert !ENV.key?("VMA_HOST_VMA_T_SET") && !ENV.key?("VMA_APPIMAGE_ENV")
|
|
69
|
+
out = IO.popen(["sh", "-c", "echo \"$VMA_T_SET|${VMA_T_UNSET-unset}\""], &:read)
|
|
70
|
+
assert_eq "host value|unset\n", out
|
|
71
|
+
ensure
|
|
72
|
+
ENV.replace(saved)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Only from the AppImage (AppRun exports APPDIR)
|
|
76
|
+
def test_appimage_children_get_host_environment
|
|
77
|
+
appdir = ENV["APPDIR"]
|
|
78
|
+
skip "not running from the AppImage" if appdir.nil?
|
|
79
|
+
ok = %w[PATH APPDIR APPIMAGE ARGV0 OWD]
|
|
80
|
+
leaked = ENV.reject { |k, v| ok.include?(k) || !v.include?(appdir) }
|
|
81
|
+
assert leaked.empty?, "still pointing into the AppImage: #{leaked.keys.join(", ")}"
|
|
82
|
+
# What the restore must not break: things loaded on first use
|
|
83
|
+
require "vte4"
|
|
84
|
+
assert Vte::Terminal.new
|
|
85
|
+
assert Gst::ElementFactory.make("playbin"), "playbin (bundled GStreamer plugins)"
|
|
86
|
+
png = Dir.glob("#{appdir}/usr/share/icons/hicolor/**/*.png").first || "#{appdir}/vimamsa.png"
|
|
87
|
+
assert GdkPixbuf::Pixbuf.new(file: png)
|
|
88
|
+
# The bundled ruby-lsp still runs (its wrapper drops the user's GEM_HOME)
|
|
89
|
+
out = IO.popen(["ruby-lsp", "--version"], err: [:child, :out], &:read)
|
|
90
|
+
assert out =~ /\d+\.\d+/, "ruby-lsp --version: #{out}"
|
|
91
|
+
end
|
|
92
|
+
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 :toggle_highlight_colors
|
|
72
|
+
assert_eq false, cnf.modules.color_highlight.enabled?
|
|
73
|
+
act :toggle_highlight_colors
|
|
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
|