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,269 @@
|
|
|
1
|
+
require "tmpdir"
|
|
2
|
+
|
|
3
|
+
# alt-h / alt-l switch to the previous/next file in the file panel's display
|
|
4
|
+
# order (dirs sorted by name, files sorted within each dir) while the panel is
|
|
5
|
+
# open, and do nothing while it is hidden. See FileTreePanel#select_adjacent.
|
|
6
|
+
class TestFilePanel < VmaTest
|
|
7
|
+
|
|
8
|
+
# Two files in one fresh temp dir: adjacent names in the same dir group are
|
|
9
|
+
# guaranteed adjacent in the flattened panel order, whatever other buffers
|
|
10
|
+
# exist from earlier tests.
|
|
11
|
+
def with_two_files(same_content: false)
|
|
12
|
+
Dir.mktmpdir do |dir|
|
|
13
|
+
fa = File.join(dir, "aaa.txt")
|
|
14
|
+
fb = File.join(dir, "bbb.txt")
|
|
15
|
+
File.write(fa, same_content ? "x\n" : "a\n")
|
|
16
|
+
File.write(fb, same_content ? "x\n" : "b\n")
|
|
17
|
+
ba = open_new_file(fa)
|
|
18
|
+
bb = open_new_file(fb)
|
|
19
|
+
begin
|
|
20
|
+
yield ba, bb
|
|
21
|
+
ensure
|
|
22
|
+
vma.buffers.close_buffer(ba.id)
|
|
23
|
+
vma.buffers.close_buffer(bb.id)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def with_panel_open
|
|
29
|
+
act :toggle_file_panel unless vma.gui.file_panel_shown?
|
|
30
|
+
yield
|
|
31
|
+
ensure
|
|
32
|
+
act :toggle_file_panel if vma.gui.file_panel_shown?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_alt_h_l_move_in_panel_order
|
|
36
|
+
with_two_files do |ba, bb|
|
|
37
|
+
with_panel_open do
|
|
38
|
+
assert_eq bb.id, vma.buf.id # opened last
|
|
39
|
+
keys("alt-h") # prev file in panel order
|
|
40
|
+
assert_eq ba.id, vma.buf.id
|
|
41
|
+
keys("alt-l") # next file in panel order
|
|
42
|
+
assert_eq bb.id, vma.buf.id
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# The current file's row is bold with the brighter fg; the others are plain.
|
|
48
|
+
# Same contents: Buffer < String, so buffer identity must not use ==.
|
|
49
|
+
def test_current_file_row_is_highlighted
|
|
50
|
+
with_two_files(same_content: true) do |ba, bb|
|
|
51
|
+
with_panel_open do
|
|
52
|
+
fp = vma.gui.file_panel
|
|
53
|
+
assert_eq fp.current_markup("● bbb.txt"), fp.row_labels[bb.id]
|
|
54
|
+
assert_eq " aaa.txt", fp.row_labels[ba.id]
|
|
55
|
+
keys("alt-h")
|
|
56
|
+
assert_eq fp.current_markup("● aaa.txt"), fp.row_labels[ba.id]
|
|
57
|
+
assert_eq " bbb.txt", fp.row_labels[bb.id]
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# g s labels the panel's file rows; typing a label switches to that file.
|
|
63
|
+
# Labels follow panel order: first file row gets "A", second "S", ...
|
|
64
|
+
def test_easy_jump_picks_file_by_label
|
|
65
|
+
with_two_files do |ba, bb|
|
|
66
|
+
with_panel_open do
|
|
67
|
+
assert_eq bb.id, vma.buf.id
|
|
68
|
+
keys("g s")
|
|
69
|
+
assert vma.gui.file_panel.easy_jump_active?, "picker should be active after g s"
|
|
70
|
+
# ba ("aaa.txt") sorts first in its dir group; find its label.
|
|
71
|
+
label = nil
|
|
72
|
+
vma.gui.file_panel.instance_variable_get(:@ej_targets).each do |l, id|
|
|
73
|
+
label = l if id == ba.id
|
|
74
|
+
end
|
|
75
|
+
assert label, "no label assigned to aaa.txt"
|
|
76
|
+
# one token per keystroke (labels are 2 chars when many buffers exist)
|
|
77
|
+
keys(label.downcase.chars.join(" "))
|
|
78
|
+
assert_eq ba.id, vma.buf.id
|
|
79
|
+
assert_eq false, vma.gui.file_panel.easy_jump_active?
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# g s labels are reddish markup spans in front of the (escaped) file name.
|
|
85
|
+
def test_easy_jump_labels_are_colored
|
|
86
|
+
with_two_files do |ba, bb|
|
|
87
|
+
with_panel_open do
|
|
88
|
+
fp = vma.gui.file_panel
|
|
89
|
+
keys("g s")
|
|
90
|
+
label = fp.instance_variable_get(:@ej_targets).key(ba.id)
|
|
91
|
+
markup = fp.row_labels[ba.id]
|
|
92
|
+
assert markup.start_with?(fp.ej_label_markup(label)), "label span missing: #{markup}"
|
|
93
|
+
assert markup.include?(fp.panel_color(:file_panel_ej_label_fg))
|
|
94
|
+
assert markup.end_with?("aaa.txt")
|
|
95
|
+
# the current row's label keeps its own span ahead of the bold name
|
|
96
|
+
cur = fp.row_labels[bb.id]
|
|
97
|
+
assert cur.start_with?(fp.ej_label_markup(fp.instance_variable_get(:@ej_targets).key(bb.id)))
|
|
98
|
+
keys("esc")
|
|
99
|
+
assert_eq false, fp.row_labels[ba.id].include?("<span")
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Row text is markup, so file names with markup chars must be escaped.
|
|
105
|
+
def test_file_name_markup_is_escaped
|
|
106
|
+
Dir.mktmpdir do |dir|
|
|
107
|
+
fn = File.join(dir, "a&<b>.txt")
|
|
108
|
+
File.write(fn, "x\n")
|
|
109
|
+
b = open_new_file(fn)
|
|
110
|
+
begin
|
|
111
|
+
with_panel_open do
|
|
112
|
+
assert vma.gui.file_panel.row_labels[b.id].include?("a&<b>.txt")
|
|
113
|
+
end
|
|
114
|
+
ensure
|
|
115
|
+
vma.buffers.close_buffer(b.id)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def test_easy_jump_esc_cancels
|
|
121
|
+
with_two_files do |ba, bb|
|
|
122
|
+
with_panel_open do
|
|
123
|
+
before = vma.buf.id
|
|
124
|
+
keys("g s")
|
|
125
|
+
assert vma.gui.file_panel.easy_jump_active?
|
|
126
|
+
keys("esc")
|
|
127
|
+
assert_eq false, vma.gui.file_panel.easy_jump_active?
|
|
128
|
+
assert_eq before, vma.buf.id
|
|
129
|
+
# keyboard override removed: normal keys work again (alt-h moves)
|
|
130
|
+
keys("alt-h")
|
|
131
|
+
assert_eq ba.id, vma.buf.id
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def test_easy_jump_noop_when_panel_hidden
|
|
137
|
+
with_two_files do |ba, bb|
|
|
138
|
+
before = vma.buf.id
|
|
139
|
+
keys("g s")
|
|
140
|
+
assert_eq false, !!vma.gui.file_panel.easy_jump_active?
|
|
141
|
+
assert_eq before, vma.buf.id
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def test_alt_h_l_noop_when_panel_hidden
|
|
146
|
+
with_two_files do |ba, bb|
|
|
147
|
+
assert_eq false, !!vma.gui.file_panel_shown?
|
|
148
|
+
before = vma.buf.id
|
|
149
|
+
keys("alt-h")
|
|
150
|
+
assert_eq before, vma.buf.id
|
|
151
|
+
keys("alt-l")
|
|
152
|
+
assert_eq before, vma.buf.id
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# File rows carry a close (x) icon right in front of the name; folder rows
|
|
157
|
+
# don't. Press shows a pressed background; release on the same button
|
|
158
|
+
# closes the file, release elsewhere cancels.
|
|
159
|
+
def test_close_button_closes_file
|
|
160
|
+
with_two_files do |ba, bb|
|
|
161
|
+
with_panel_open do
|
|
162
|
+
fp = vma.gui.file_panel
|
|
163
|
+
drain_idle # lay out the tree so cell areas exist
|
|
164
|
+
fp.file_rows.each_value { |it| assert it[FileTreePanel::COL_CLOSE].include?(FileTreePanel::CLOSE_GLYPH) }
|
|
165
|
+
fp.instance_variable_get(:@store).each do |_m, _p, it|
|
|
166
|
+
assert_eq nil, it[FileTreePanel::COL_CLOSE] if it[FileTreePanel::COL_BUF_ID] == 0
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# hit test: the icon cell hits, the name text right after it doesn't
|
|
170
|
+
x, y = fp.close_button_center(ba.id)
|
|
171
|
+
assert_eq ba.id, fp.close_hit(x, y)
|
|
172
|
+
assert_eq nil, fp.close_hit(x + fp.close_w, y)
|
|
173
|
+
|
|
174
|
+
# hover tint, then pressed tint
|
|
175
|
+
fp.set_close_hover(ba.id)
|
|
176
|
+
assert fp.file_rows[ba.id][FileTreePanel::COL_CLOSE].include?(fp.panel_color(:file_panel_close_hover_bg))
|
|
177
|
+
fp.close_press(ba.id)
|
|
178
|
+
assert fp.file_rows[ba.id][FileTreePanel::COL_CLOSE].include?(fp.panel_color(:file_panel_close_pressed_bg))
|
|
179
|
+
assert_eq :normal, fp.close_state(bb.id)
|
|
180
|
+
|
|
181
|
+
# release off the button: cancelled, nothing closes
|
|
182
|
+
fp.close_release(nil)
|
|
183
|
+
drain_idle
|
|
184
|
+
assert fp.row_labels.key?(ba.id), "release elsewhere must not close"
|
|
185
|
+
|
|
186
|
+
# press + release on the button closes it; current file stays
|
|
187
|
+
assert_eq bb.id, vma.buf.id
|
|
188
|
+
fp.close_press(ba.id)
|
|
189
|
+
fp.close_release(ba.id)
|
|
190
|
+
drain_idle
|
|
191
|
+
assert vma.buffers.list.none? { |b| b.equal?(ba) }, "aaa.txt still open"
|
|
192
|
+
assert_eq nil, fp.row_labels[ba.id]
|
|
193
|
+
assert_eq bb.id, vma.buf.id
|
|
194
|
+
fp.set_close_hover(nil)
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Marks (m <char>) of the current file are listed above the files; clicking
|
|
200
|
+
# one jumps to it; the list follows edits and buffer switches.
|
|
201
|
+
def test_marks_section
|
|
202
|
+
with_two_files do |ba, bb|
|
|
203
|
+
with_panel_open do
|
|
204
|
+
fp = vma.gui.file_panel
|
|
205
|
+
tree = fp.instance_variable_get(:@tree)
|
|
206
|
+
store = fp.instance_variable_get(:@store)
|
|
207
|
+
bb.set_content("one\ntwo\nthree\nfour\n")
|
|
208
|
+
assert_eq({}, fp.mark_rows)
|
|
209
|
+
|
|
210
|
+
bb.set_pos(bb.line_range(2, 1).begin) # "three"
|
|
211
|
+
keys("m b")
|
|
212
|
+
bb.set_pos(bb.line_range(0, 1).begin) # "one"
|
|
213
|
+
keys("m a")
|
|
214
|
+
bb.marks["bm:1"] = 0 # bookmark entry: not a mark
|
|
215
|
+
sleep 0.4
|
|
216
|
+
drain_idle
|
|
217
|
+
assert_eq ["a", "b"], fp.mark_rows.keys
|
|
218
|
+
assert fp.mark_rows["a"].include?("1: one"), fp.mark_rows["a"]
|
|
219
|
+
assert fp.mark_rows["b"].include?("3: three"), fp.mark_rows["b"]
|
|
220
|
+
# section comes before the folder rows
|
|
221
|
+
first = store.iter_first
|
|
222
|
+
assert_eq "", first[FileTreePanel::COL_MARK]
|
|
223
|
+
|
|
224
|
+
# click mark b -> cursor on "three"
|
|
225
|
+
path = nil
|
|
226
|
+
store.each { |_m, pth, it| path = pth if it[FileTreePanel::COL_MARK] == "b" }
|
|
227
|
+
tree.row_activated(path, tree.get_column(0))
|
|
228
|
+
assert_eq 2, bb.lpos
|
|
229
|
+
|
|
230
|
+
# edit above the marks: line numbers follow
|
|
231
|
+
bb.insert_txt_at("new\n", 0)
|
|
232
|
+
sleep 0.4
|
|
233
|
+
drain_idle
|
|
234
|
+
assert fp.mark_rows["b"].include?("4: three"), fp.mark_rows["b"]
|
|
235
|
+
|
|
236
|
+
# another file: its (no) marks are shown instead
|
|
237
|
+
keys("alt-h")
|
|
238
|
+
assert_eq ba.id, vma.buf.id
|
|
239
|
+
assert_eq({}, fp.mark_rows)
|
|
240
|
+
assert_eq 0, store.iter_first[FileTreePanel::COL_BUF_ID]
|
|
241
|
+
assert store.iter_first[FileTreePanel::COL_MARK].nil?, "marks header left behind"
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
# A mark on an empty line shows the nearest non-empty line, with an arrow
|
|
247
|
+
# telling whether it is below or above (a tie goes to the line below).
|
|
248
|
+
def test_mark_on_empty_line_shows_nearest_text
|
|
249
|
+
with_two_files do |_ba, bb|
|
|
250
|
+
with_panel_open do
|
|
251
|
+
fp = vma.gui.file_panel
|
|
252
|
+
bb.set_content("title\n\n\n\nbody\n\nend\n \n\n")
|
|
253
|
+
{ "a" => 1, "b" => 3, "c" => 2, "d" => 5, "e" => 7, "f" => 0 }.each do |c, l|
|
|
254
|
+
bb.set_pos(bb.line_range(l, 1).begin)
|
|
255
|
+
keys("m #{c}")
|
|
256
|
+
end
|
|
257
|
+
sleep 0.4
|
|
258
|
+
drain_idle
|
|
259
|
+
rows = fp.mark_rows
|
|
260
|
+
assert rows["a"].end_with?("2: ↑ title"), rows["a"] # title is 1 above
|
|
261
|
+
assert rows["b"].end_with?("4: ↓ body"), rows["b"] # body is 1 below
|
|
262
|
+
assert rows["c"].end_with?("3: ↓ body"), rows["c"] # 2 either way: below
|
|
263
|
+
assert rows["d"].end_with?("6: ↓ end"), rows["d"]
|
|
264
|
+
assert rows["e"].end_with?("8: ↑ end"), rows["e"] # whitespace-only line
|
|
265
|
+
assert rows["f"].end_with?("1: title"), rows["f"] # non-empty: no arrow
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
end
|
data/tests/test_flash.rb
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Gui.flash_range visualises the yanked/deleted range with a brief highlight,
|
|
2
|
+
# deferring the delete via a GLib timeout. That deferral must NOT happen during
|
|
3
|
+
# macro playback — it reorders the delete relative to the rest of the macro and
|
|
4
|
+
# breaks it. This test verifies the macro guard forces the synchronous path.
|
|
5
|
+
#
|
|
6
|
+
# Flashing is normally inactive under --test, so the test temporarily removes
|
|
7
|
+
# that guard to exercise the real active-decision.
|
|
8
|
+
|
|
9
|
+
class TestFlash < VmaTest
|
|
10
|
+
def test_flash_synchronous_during_macro
|
|
11
|
+
act('buf.insert_txt("AAAA\nBBBB\n")')
|
|
12
|
+
# Need a real view for the deferred path to be reachable; otherwise the
|
|
13
|
+
# synchronous fallback would fire regardless of the macro guard.
|
|
14
|
+
skip("no GUI view in this environment") unless buf.view
|
|
15
|
+
|
|
16
|
+
had_test = ARGV.delete("--test")
|
|
17
|
+
cnf.flash.enabled = true
|
|
18
|
+
begin
|
|
19
|
+
ran = false
|
|
20
|
+
vma.macro.instance_variable_set(:@running_macro, true)
|
|
21
|
+
Gui.flash_range(buf, 0..1) { ran = true }
|
|
22
|
+
assert(ran, "flash block must run synchronously while a macro is running")
|
|
23
|
+
ensure
|
|
24
|
+
vma.macro.instance_variable_set(:@running_macro, false)
|
|
25
|
+
ARGV.push("--test") if had_test
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Sanity: with no macro running (and --test removed), flashing defers the
|
|
30
|
+
# block, so it has NOT run by the time flash_range returns — then fires after
|
|
31
|
+
# the timeout. This proves the synchronous test above is not a false positive.
|
|
32
|
+
def test_flash_defers_when_not_in_macro
|
|
33
|
+
act('buf.insert_txt("AAAA\nBBBB\n")')
|
|
34
|
+
skip("no GUI view in this environment") unless buf.view
|
|
35
|
+
|
|
36
|
+
had_test = ARGV.delete("--test")
|
|
37
|
+
prev_dur = cnf.flash.duration!
|
|
38
|
+
cnf.flash.enabled = true
|
|
39
|
+
cnf.flash.duration = 0.01 # keep the deferral short so the test is fast
|
|
40
|
+
begin
|
|
41
|
+
ran = false
|
|
42
|
+
Gui.flash_range(buf, 0..1) { ran = true }
|
|
43
|
+
assert(!ran, "flash block should be deferred (not yet run) outside a macro")
|
|
44
|
+
# Let the timeout fire so the deferred cleanup completes (no leak into
|
|
45
|
+
# later tests).
|
|
46
|
+
deadline = Time.now + 2
|
|
47
|
+
GLib::MainContext.default.iteration(true) while !ran && Time.now < deadline
|
|
48
|
+
assert(ran, "deferred flash block should run after the timeout")
|
|
49
|
+
ensure
|
|
50
|
+
cnf.flash.duration = prev_dur
|
|
51
|
+
ARGV.push("--test") if had_test
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# A key pressed while a delete is still flashing must see the delete
|
|
56
|
+
# already done. Typing "d w j" faster than cnf.flash.duration used to run
|
|
57
|
+
# j first; the deferred delete then snapped the cursor back to line 0
|
|
58
|
+
# (and a macro recorded that way replayed from the wrong place).
|
|
59
|
+
def test_key_during_flash_runs_pending_delete_first
|
|
60
|
+
act('buf.insert_txt(" sdf sdfsdf\n sdf sdfsdf\n sdf sdfsdf")')
|
|
61
|
+
skip("no GUI view in this environment") unless buf.view
|
|
62
|
+
act :jump_to_start_of_buffer
|
|
63
|
+
|
|
64
|
+
had_test = ARGV.delete("--test")
|
|
65
|
+
prev_dur = cnf.flash.duration!
|
|
66
|
+
cnf.flash.enabled = true
|
|
67
|
+
cnf.flash.duration = 5 # long enough that it can't fire during the test
|
|
68
|
+
begin
|
|
69
|
+
keys "d w j"
|
|
70
|
+
assert_buf "sdf sdfsdf\n sdf sdfsdf\n sdf sdfsdf\n"
|
|
71
|
+
assert_pos 1, 0
|
|
72
|
+
ensure
|
|
73
|
+
Gui.flush_flash
|
|
74
|
+
cnf.flash.duration = prev_dur
|
|
75
|
+
ARGV.push("--test") if had_test
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
data/tests/test_fold.rb
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Tests for vim-style marker folds ({{{ ... }}}) — see lib/vimamsa/fold.rb.
|
|
2
|
+
# Enter on a fold-start / placeholder line toggles the fold; the folded body is
|
|
3
|
+
# extracted from the buffer and re-inflated for any disk write.
|
|
4
|
+
|
|
5
|
+
class TestFold < VmaTest
|
|
6
|
+
|
|
7
|
+
BLOCK = "{{{ Title\nline a\nline b\n}}}\n"
|
|
8
|
+
COLLAPSED = "{{{ Title ⟨4 lines⟩\n"
|
|
9
|
+
|
|
10
|
+
# Seed the buffer with `text` and park the cursor on line 0, command mode.
|
|
11
|
+
# The fresh test buffer is already "\n", so chomp `text`'s trailing newline to
|
|
12
|
+
# avoid a doubled final blank line.
|
|
13
|
+
def seed(text)
|
|
14
|
+
act "buf.insert_txt(#{text.chomp.inspect})"
|
|
15
|
+
act "buf.set_pos(0)"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_close_collapses_block
|
|
19
|
+
seed(BLOCK)
|
|
20
|
+
keys("enter") # Enter on the {{{ line closes the fold
|
|
21
|
+
assert_buf COLLAPSED
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_open_restores_block_exactly
|
|
25
|
+
seed(BLOCK)
|
|
26
|
+
keys("enter") # close
|
|
27
|
+
assert_buf COLLAPSED
|
|
28
|
+
keys("enter") # Enter on the placeholder re-opens it
|
|
29
|
+
assert_buf BLOCK # byte-exact round-trip
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# The core Approach-B correctness guarantee: while collapsed, the on-disk
|
|
33
|
+
# serialisation must still be the fully expanded text.
|
|
34
|
+
def test_content_for_disk_is_inflated_while_closed
|
|
35
|
+
seed(BLOCK)
|
|
36
|
+
keys("enter")
|
|
37
|
+
assert_buf COLLAPSED
|
|
38
|
+
assert_eq BLOCK, vma.buf.content_for_disk
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Folding must not clobber the clipboard (uses add_delta, not delete_range).
|
|
42
|
+
def test_close_does_not_touch_clipboard
|
|
43
|
+
seed(BLOCK)
|
|
44
|
+
before = vma.clipboard.get()
|
|
45
|
+
keys("enter")
|
|
46
|
+
assert_eq before, vma.clipboard.get()
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# A single undo reverses a close.
|
|
50
|
+
def test_undo_reverses_close
|
|
51
|
+
seed(BLOCK)
|
|
52
|
+
keys("enter")
|
|
53
|
+
assert_buf COLLAPSED
|
|
54
|
+
act :undo
|
|
55
|
+
assert_buf BLOCK
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Enter on an ordinary (non-fold) line does not consume the key as a fold
|
|
59
|
+
# toggle — the buffer text is unchanged by the toggle path.
|
|
60
|
+
def test_enter_on_plain_line_is_not_a_fold
|
|
61
|
+
seed("hello\nworld\n")
|
|
62
|
+
act "buf.set_pos(0)" # line 0 = "hello", not a fold marker
|
|
63
|
+
keys("enter")
|
|
64
|
+
# fold_toggle_at returns false; buffer text is not collapsed.
|
|
65
|
+
assert_eq false, vma.buf.fold_toggle_at(0)
|
|
66
|
+
assert_buf "hello\nworld\n"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# cnf.fold.start_closed (default): content set via set_content — the path all
|
|
70
|
+
# file loads and reverts go through — arrives with every fold collapsed, with
|
|
71
|
+
# no undo history for the collapse, and still serialises fully expanded.
|
|
72
|
+
def test_start_closed_collapses_on_load
|
|
73
|
+
act "buf.set_content(#{("before\n" + BLOCK + "after\n").inspect})"
|
|
74
|
+
assert_buf "before\n#{COLLAPSED}after\n"
|
|
75
|
+
assert_eq "before\n#{BLOCK}after\n", vma.buf.content_for_disk
|
|
76
|
+
act "buf.set_pos(#{"before\n".size})"
|
|
77
|
+
keys("enter") # placeholder opens like a manually closed fold
|
|
78
|
+
assert_buf "before\n#{BLOCK}after\n"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_start_closed_collapses_multiple_blocks
|
|
82
|
+
act "buf.set_content(#{(BLOCK + "mid\n" + "{{{\nx\n}}}\n").inspect})"
|
|
83
|
+
assert_buf "#{COLLAPSED}mid\n{{{ ⟨3 lines⟩\n"
|
|
84
|
+
assert_eq "#{BLOCK}mid\n{{{\nx\n}}}\n", vma.buf.content_for_disk
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# An unbalanced {{{ line (no matching }}}) is left as plain text at load.
|
|
88
|
+
def test_start_closed_leaves_unbalanced_marker_alone
|
|
89
|
+
act "buf.set_content(#{"{{{ dangling\nrest\n".inspect})"
|
|
90
|
+
assert_buf "{{{ dangling\nrest\n"
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def test_start_closed_disabled_keeps_expanded
|
|
94
|
+
act "cnf.fold.start_closed = false"
|
|
95
|
+
act "buf.set_content(#{BLOCK.inspect})"
|
|
96
|
+
assert_buf BLOCK
|
|
97
|
+
ensure
|
|
98
|
+
act "cnf.fold.start_closed = true"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# A fold containing a nested fold collapses to one line and round-trips.
|
|
102
|
+
def test_nested_fold_round_trip
|
|
103
|
+
nested = "{{{ outer\na\n{{{ inner\nb\n}}}\nc\n}}}\n"
|
|
104
|
+
seed(nested)
|
|
105
|
+
keys("enter") # close outer
|
|
106
|
+
assert_eq "{{{ outer ⟨7 lines⟩\n", vma.buf.to_s
|
|
107
|
+
assert_eq nested, vma.buf.content_for_disk
|
|
108
|
+
keys("enter") # open outer
|
|
109
|
+
assert_buf nested
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
# Test that changing font size via settings applies to all open buffers,
|
|
3
|
+
# not just the one currently visible in the active window.
|
|
4
|
+
#
|
|
5
|
+
# gui_refresh_font iterates $vmag.windows (at most 2 visible panels), so
|
|
6
|
+
# background buffers whose views are not mounted in any window are at risk
|
|
7
|
+
# of being skipped. This test creates several buffers, triggers a font
|
|
8
|
+
# refresh, then verifies that every buffer view received the CSS provider.
|
|
9
|
+
|
|
10
|
+
class TestFontRefreshAllBuffers < VmaTest
|
|
11
|
+
|
|
12
|
+
def test_font_applied_to_all_buffer_views
|
|
13
|
+
# Create extra buffers (setcurrent=false → they stay in the background)
|
|
14
|
+
b2 = create_new_buffer("second buffer\n", "b2", false)
|
|
15
|
+
b3 = create_new_buffer("third buffer\n", "b3", false)
|
|
16
|
+
drain_idle
|
|
17
|
+
|
|
18
|
+
all_views = vma.gui.buffers.dup # {buf_id => VSourceView}
|
|
19
|
+
|
|
20
|
+
# Need at least 3 buffers (setup adds one, we added two more)
|
|
21
|
+
assert all_views.size >= 3,
|
|
22
|
+
"Expected >= 3 buffer views, got #{all_views.size}"
|
|
23
|
+
|
|
24
|
+
# Intercept add_provider to record which view style-contexts are touched.
|
|
25
|
+
# We prepend once; subsequent test runs also benefit from the tracking
|
|
26
|
+
# because provider_received is replaced each time.
|
|
27
|
+
provider_received = {}
|
|
28
|
+
all_views.each_value { |v| provider_received[v.style_context.object_id] = false }
|
|
29
|
+
|
|
30
|
+
orig = Gtk::StyleContext.instance_method(:add_provider)
|
|
31
|
+
tracker = Module.new do
|
|
32
|
+
define_method(:add_provider) do |prov|
|
|
33
|
+
provider_received[object_id] = true if provider_received.key?(object_id)
|
|
34
|
+
orig.bind(self).call(prov)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
Gtk::StyleContext.prepend(tracker)
|
|
38
|
+
|
|
39
|
+
original_size = get(cnf.font.size)
|
|
40
|
+
new_size = original_size + 4
|
|
41
|
+
cnf.font.size = new_size
|
|
42
|
+
gui_refresh_font
|
|
43
|
+
drain_idle
|
|
44
|
+
|
|
45
|
+
all_views.each do |buf_id, view|
|
|
46
|
+
sc_id = view.style_context.object_id
|
|
47
|
+
assert provider_received[sc_id],
|
|
48
|
+
"Font CSS provider was NOT applied to buffer #{buf_id} (view id #{view.object_id})"
|
|
49
|
+
end
|
|
50
|
+
ensure
|
|
51
|
+
# Restore original font size so other tests are not affected
|
|
52
|
+
cnf.font.size = original_size if defined?(original_size) && original_size
|
|
53
|
+
gui_refresh_font rescue nil
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
class TestFuncPanel < VmaTest
|
|
2
|
+
# Regression: toggling the function panel with LSP disabled used to raise
|
|
3
|
+
# NameError (uninitialized constant LangSrv) inside the GTK callback and
|
|
4
|
+
# crash the whole app. It must now degrade to a "(no LSP)" placeholder.
|
|
5
|
+
def test_toggle_func_panel_no_lsp_does_not_raise
|
|
6
|
+
prev = cnf.lsp.enabled?
|
|
7
|
+
cnf.lsp.enabled = false
|
|
8
|
+
act :toggle_func_panel # open
|
|
9
|
+
act :toggle_func_panel # close
|
|
10
|
+
assert true, "no exception raised"
|
|
11
|
+
ensure
|
|
12
|
+
cnf.lsp.enabled = prev
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_refresh_no_lsp_sets_placeholder
|
|
16
|
+
prev = cnf.lsp.enabled?
|
|
17
|
+
cnf.lsp.enabled = false
|
|
18
|
+
vma.buf.set_content("def foo\nend\n")
|
|
19
|
+
vma.buf.instance_variable_set(:@fname, "/tmp/func_panel_test.rb") # exercise the LangSrv guard
|
|
20
|
+
fp = Vimamsa::FuncPanel.new
|
|
21
|
+
fp.refresh
|
|
22
|
+
store = fp.instance_variable_get(:@store)
|
|
23
|
+
names = []
|
|
24
|
+
store.each { |_model, _path, iter| names << iter[Vimamsa::FuncPanel::COL_NAME] }
|
|
25
|
+
assert_eq ["(no LSP)"], names, "placeholder row set"
|
|
26
|
+
rescue NameError => e
|
|
27
|
+
raise VmaTestFailure, "refresh raised NameError: #{e.message}"
|
|
28
|
+
ensure
|
|
29
|
+
cnf.lsp.enabled = prev
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def test_refresh_hyperplaintext_uses_titles_and_headings_without_lsp
|
|
33
|
+
prev = cnf.lsp.enabled?
|
|
34
|
+
cnf.lsp.enabled = false
|
|
35
|
+
vma.buf.set_content("❙ Project Notes ❙\nBody\n◼ Alpha\nText\n◼◼ Beta\n")
|
|
36
|
+
vma.buf.instance_variable_set(:@fname, "/tmp/func_panel_test.txt")
|
|
37
|
+
vma.buf.set_filename(vma.buf.fname)
|
|
38
|
+
fp = Vimamsa::FuncPanel.new
|
|
39
|
+
fp.refresh
|
|
40
|
+
store = fp.instance_variable_get(:@store)
|
|
41
|
+
names = []
|
|
42
|
+
lines = []
|
|
43
|
+
store.each do |_model, _path, iter|
|
|
44
|
+
names << iter[Vimamsa::FuncPanel::COL_NAME]
|
|
45
|
+
lines << iter[Vimamsa::FuncPanel::COL_LINE]
|
|
46
|
+
end
|
|
47
|
+
assert_eq ["Project Notes", "Alpha", "Beta"], names, "hyperplaintext outline rows"
|
|
48
|
+
assert_eq [1, 3, 5], lines, "hyperplaintext outline line numbers"
|
|
49
|
+
ensure
|
|
50
|
+
cnf.lsp.enabled = prev
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_refresh_hyperplaintext_without_outline_sets_placeholder
|
|
54
|
+
prev = cnf.lsp.enabled?
|
|
55
|
+
cnf.lsp.enabled = false
|
|
56
|
+
vma.buf.set_content("plain text\nmore text\n")
|
|
57
|
+
vma.buf.instance_variable_set(:@fname, "/tmp/func_panel_test.txt")
|
|
58
|
+
vma.buf.set_filename(vma.buf.fname)
|
|
59
|
+
fp = Vimamsa::FuncPanel.new
|
|
60
|
+
fp.refresh
|
|
61
|
+
store = fp.instance_variable_get(:@store)
|
|
62
|
+
names = []
|
|
63
|
+
store.each { |_model, _path, iter| names << iter[Vimamsa::FuncPanel::COL_NAME] }
|
|
64
|
+
assert_eq ["(no headings)"], names, "placeholder row set"
|
|
65
|
+
ensure
|
|
66
|
+
cnf.lsp.enabled = prev
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
class TestGrepApply < VmaTest
|
|
2
|
+
def setup_grep
|
|
3
|
+
@orig_experimental = cnf.experimental?
|
|
4
|
+
cnf.experimental = true
|
|
5
|
+
@orig = vma.buf
|
|
6
|
+
act 'buf.insert_txt("foo one\nbar\nfoo two\n")'
|
|
7
|
+
Grep.new.callback("foo")
|
|
8
|
+
drain_idle
|
|
9
|
+
assert_buf "1:foo one\n3:foo two\n"
|
|
10
|
+
assert_mode :grep
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def edit_first_match
|
|
14
|
+
act 'buf.set_pos(2)'
|
|
15
|
+
keys "i X esc"
|
|
16
|
+
assert_buf "1:Xfoo one\n3:foo two\n"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_ctrl_s_applies_changes
|
|
20
|
+
setup_grep
|
|
21
|
+
edit_first_match
|
|
22
|
+
keys "ctrl-s"
|
|
23
|
+
assert_eq "Xfoo one\nbar\nfoo two\n\n", @orig.to_s
|
|
24
|
+
ensure
|
|
25
|
+
cnf.experimental = @orig_experimental
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_ctrl_s_in_insert_mode_applies_changes
|
|
29
|
+
setup_grep
|
|
30
|
+
edit_first_match
|
|
31
|
+
keys "i ctrl-s"
|
|
32
|
+
assert_eq "Xfoo one\nbar\nfoo two\n\n", @orig.to_s
|
|
33
|
+
keys "esc"
|
|
34
|
+
ensure
|
|
35
|
+
cnf.experimental = @orig_experimental
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_shift_no_longer_applies_changes
|
|
39
|
+
setup_grep
|
|
40
|
+
edit_first_match
|
|
41
|
+
keys "shift"
|
|
42
|
+
assert_eq "foo one\nbar\nfoo two\n\n", @orig.to_s
|
|
43
|
+
ensure
|
|
44
|
+
cnf.experimental = @orig_experimental
|
|
45
|
+
end
|
|
46
|
+
end
|