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,281 @@
|
|
|
1
|
+
require "tmpdir"
|
|
2
|
+
|
|
3
|
+
# Does LSP work for C++ with clangd, configured exactly as in custom.rb:
|
|
4
|
+
#
|
|
5
|
+
# cnf.lsp.enabled = true
|
|
6
|
+
# cnf.lsp.server.clangd = { name: "clangd", command: "clangd --offset-encoding=utf-8", type: "stdio" }
|
|
7
|
+
# cnf.lsp.server.clangd.languages = ["c", "cpp"]
|
|
8
|
+
#
|
|
9
|
+
# Uses a small C++ file in a temp dir (with compile_flags.txt, so clangd needs
|
|
10
|
+
# no build setup). Uses `clangd`, or else the newest working `clangd-NN` on
|
|
11
|
+
# PATH (Ubuntu installs e.g. clangd-12 without the bare name). Skips if none
|
|
12
|
+
# runs; any other problem (server fails to start, wrong answers) is a failure.
|
|
13
|
+
#
|
|
14
|
+
# Run explicitly:
|
|
15
|
+
# ruby exe/run_tests.rb lsp_clangd
|
|
16
|
+
|
|
17
|
+
class TestLspClangd < VmaTest
|
|
18
|
+
SRC = <<~CPP
|
|
19
|
+
struct Point { int x; int y; };
|
|
20
|
+
|
|
21
|
+
int add(int a, int b) { return a + b; }
|
|
22
|
+
|
|
23
|
+
int main() {
|
|
24
|
+
Point p{1, 2};
|
|
25
|
+
int s = add(p.x, p.y);
|
|
26
|
+
const char *u = "ää"; int t = add(1, 2);
|
|
27
|
+
return s + t + p.
|
|
28
|
+
}
|
|
29
|
+
CPP
|
|
30
|
+
|
|
31
|
+
# First clangd binary on PATH that runs, or nil.
|
|
32
|
+
def self.clangd_bin
|
|
33
|
+
return @clangd_bin if defined?(@clangd_bin)
|
|
34
|
+
cands = ["clangd"] + 40.downto(9).map { |n| "clangd-#{n}" }
|
|
35
|
+
@clangd_bin = cands.find { |c| system("#{c} --version > /dev/null 2>&1") }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def configure_clangd
|
|
39
|
+
require "vimamsa/langservp"
|
|
40
|
+
cnf.lsp.enabled = true
|
|
41
|
+
cnf.lsp.server.clangd = { name: "clangd", command: "#{self.class.clangd_bin} --offset-encoding=utf-8", type: "stdio" }
|
|
42
|
+
cnf.lsp.server.clangd.languages = ["c", "cpp"]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Opens the C++ file with the settings above, yields [buffer, lsp, path, dir].
|
|
46
|
+
# One clangd process is shared by all tests of this class.
|
|
47
|
+
def with_clangd
|
|
48
|
+
skip "clangd not on PATH" if self.class.clangd_bin.nil?
|
|
49
|
+
configure_clangd
|
|
50
|
+
@@reset ||= %w[c cpp].each { |l| LangSrv.class_variable_get(:@@languages).delete(l) }
|
|
51
|
+
Dir.mktmpdir("vma_clangd") do |dir|
|
|
52
|
+
File.write(File.join(dir, "compile_flags.txt"), "-std=c++17\n")
|
|
53
|
+
path = File.join(dir, "main.cpp")
|
|
54
|
+
File.write(path, SRC)
|
|
55
|
+
b = open_new_file(path)
|
|
56
|
+
begin
|
|
57
|
+
drain_idle
|
|
58
|
+
assert b.lsp, "LSP did not start for #{File.basename(path)} (lang #{b.lang.inspect}): " \
|
|
59
|
+
"clangd failed to start or did not answer 'initialize' within 5 s"
|
|
60
|
+
yield b, b.lsp, path, dir
|
|
61
|
+
ensure
|
|
62
|
+
vma.buffers.close_buffer(b.id)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
ensure
|
|
66
|
+
cnf.lsp.enabled = false
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# [line, char] (0-based, Ruby chars) of the n-th occurrence of str in SRC
|
|
70
|
+
def loc(str, n = 0)
|
|
71
|
+
SRC.lines.each_with_index do |l, i|
|
|
72
|
+
col = -1
|
|
73
|
+
while (col = l.index(str, col + 1))
|
|
74
|
+
return [i, col] if n == 0
|
|
75
|
+
n -= 1
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
raise "#{str} not in SRC"
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# clangd parses in the background after didOpen: retry until non-empty.
|
|
82
|
+
def retry_until(tries = 20)
|
|
83
|
+
r = nil
|
|
84
|
+
tries.times do
|
|
85
|
+
r = yield
|
|
86
|
+
break if r && !(r.respond_to?(:empty?) && r.empty?)
|
|
87
|
+
sleep 0.5
|
|
88
|
+
drain_idle
|
|
89
|
+
end
|
|
90
|
+
r
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def test_document_symbols
|
|
94
|
+
with_clangd do |_b, lsp, path|
|
|
95
|
+
funcs = retry_until { lsp.document_functions(path) }
|
|
96
|
+
assert funcs && !funcs.empty?, "no documentSymbol answer from clangd"
|
|
97
|
+
names = funcs.map { |f| f[:name] }
|
|
98
|
+
assert names.include?("add") && names.include?("main"), "functions: #{names.inspect}"
|
|
99
|
+
assert_eq loc("int add")[0] + 1, funcs.find { |f| f[:name] == "add" }[:line]
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def test_jump_to_definition
|
|
104
|
+
with_clangd do |_b, lsp, path|
|
|
105
|
+
line, col = loc("add(p")
|
|
106
|
+
d = retry_until { lsp.get_definition(path, line, col) }
|
|
107
|
+
assert d, "no definition for `add` at #{line}:#{col}"
|
|
108
|
+
assert_eq File.realpath(path), File.realpath(d[0])
|
|
109
|
+
assert_eq loc("int add")[0] + 1, d[1]
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Non-ASCII text before the cursor ("ää" = 2 chars, 4 bytes): the column
|
|
114
|
+
# must be sent in the server's position encoding (utf-8 bytes with
|
|
115
|
+
# --offset-encoding=utf-8, see LangSrv#lsp_character), else the lookup lands
|
|
116
|
+
# 2 bytes early, on `t`.
|
|
117
|
+
def test_jump_to_definition_after_non_ascii
|
|
118
|
+
with_clangd do |_b, lsp, path|
|
|
119
|
+
line, col = loc("add(1")
|
|
120
|
+
d = retry_until { lsp.get_definition(path, line, col) }
|
|
121
|
+
assert d, "no definition for `add` at #{line}:#{col} (line has non-ASCII text before it: " \
|
|
122
|
+
"character vs. byte offset mismatch?)"
|
|
123
|
+
assert_eq loc("int add")[0] + 1, d[1]
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Edits reach clangd: textDocument/didChange is a notification, sent without
|
|
128
|
+
# an id. With an id clangd rejected it (method not found) and kept the text
|
|
129
|
+
# as opened, so after adding lines above, a lookup at the new position of
|
|
130
|
+
# `add(p` hit what used to be there instead.
|
|
131
|
+
def test_jump_to_definition_after_edit
|
|
132
|
+
with_clangd do |b, lsp, path|
|
|
133
|
+
retry_until { lsp.get_definition(path, *loc("add(p")) } # parsed
|
|
134
|
+
b.insert_txt_at("// one\n// two\n", 0)
|
|
135
|
+
drain_idle
|
|
136
|
+
line, col = loc("add(p")
|
|
137
|
+
d = retry_until { lsp.get_definition(path, line + 2, col) }
|
|
138
|
+
assert d, "no definition for `add` after the edit"
|
|
139
|
+
assert_eq loc("int add")[0] + 1 + 2, d[1], "clangd did not see the edit"
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def test_completion
|
|
144
|
+
with_clangd do |_b, lsp, path|
|
|
145
|
+
line, col = loc("p.\n")
|
|
146
|
+
col += 2 # after "p."
|
|
147
|
+
items = retry_until(10) do
|
|
148
|
+
got = nil
|
|
149
|
+
lsp.request_completion(path, line, col) { |r| got = r }
|
|
150
|
+
20.times { break if got; sleep 0.1; drain_idle }
|
|
151
|
+
got
|
|
152
|
+
end
|
|
153
|
+
assert items && !items.empty?, "no completion items after `p.`"
|
|
154
|
+
texts = items.map { |i| i[:text] }
|
|
155
|
+
assert texts.include?("x") && texts.include?("y"), "completions: #{texts.first(20).inspect}"
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# Headers: GtkSourceView calls .hpp/.hh "cpphdr" and .h "chdr"; they must
|
|
160
|
+
# use the clangd started for "cpp"/"c" (same process as main.cpp).
|
|
161
|
+
# .hxx is unknown to GtkSourceView and falls back to "cpp".
|
|
162
|
+
def test_header_files_use_clangd
|
|
163
|
+
with_clangd do |_b, lsp, _path, dir|
|
|
164
|
+
%w[point.hpp point.hh point.hxx].each do |name|
|
|
165
|
+
hpath = File.join(dir, name)
|
|
166
|
+
File.write(hpath, "#pragma once\nstruct Pt { int x; };\ninline int twice(int v) { return 2 * v; }\n")
|
|
167
|
+
hb = open_new_file(hpath)
|
|
168
|
+
begin
|
|
169
|
+
drain_idle
|
|
170
|
+
assert hb.lsp, "no LSP for #{name} (lang #{hb.lang.inspect})"
|
|
171
|
+
assert hb.lsp.equal?(lsp), "#{name} started a separate server instead of sharing main.cpp's"
|
|
172
|
+
funcs = retry_until { hb.lsp.document_functions(hpath) }
|
|
173
|
+
assert funcs && funcs.map { |f| f[:name] }.include?("twice"), "#{name} symbols: #{funcs.inspect}"
|
|
174
|
+
ensure
|
|
175
|
+
vma.buffers.close_buffer(hb.id)
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def context_menu_labels(view)
|
|
182
|
+
m = view.instance_variable_get(:@context_menu).menu_model
|
|
183
|
+
(0...m.n_items).map { |i| m.get_item_attribute_value(i, "label", GLib::VariantType::STRING) }
|
|
184
|
+
ensure
|
|
185
|
+
view.instance_variable_get(:@context_menu)&.popdown
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Right-click menu offers "Jump to Definition" when the buffer has LSP, and
|
|
189
|
+
# choosing it jumps.
|
|
190
|
+
def test_context_menu_jump_to_definition
|
|
191
|
+
with_clangd do |b, _lsp, path|
|
|
192
|
+
line, col = loc("add(p")
|
|
193
|
+
b.set_pos(b.line_range(line, 1).begin + col)
|
|
194
|
+
b.view.show_context_menu(5, 5)
|
|
195
|
+
drain_idle
|
|
196
|
+
assert context_menu_labels(b.view).include?("Jump to Definition")
|
|
197
|
+
# show_context_menu moved the cursor to the click; put it back on `add`
|
|
198
|
+
b.set_pos(b.line_range(line, 1).begin + col)
|
|
199
|
+
sleep 1 # let clangd parse
|
|
200
|
+
vma.gui.app.lookup_action("ctx_lsp_jump_to_definition").activate(nil)
|
|
201
|
+
drain_idle
|
|
202
|
+
assert_eq loc("int add")[0], vma.buf.lpos
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def test_no_context_menu_item_without_lsp
|
|
207
|
+
b = vma.buf # plain text test buffer, LSP disabled
|
|
208
|
+
b.view.show_context_menu(5, 5)
|
|
209
|
+
drain_idle
|
|
210
|
+
assert !context_menu_labels(b.view).include?("Jump to Definition")
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# Saving an untitled buffer as .cpp attaches LSP (and the menu item).
|
|
214
|
+
def test_save_as_cpp_attaches_lsp
|
|
215
|
+
with_clangd do |_b, lsp, _path, dir|
|
|
216
|
+
nb = create_new_buffer("int main() { return 0; }\n", "untitled")
|
|
217
|
+
begin
|
|
218
|
+
assert_eq nil, nb.lsp
|
|
219
|
+
nb.save_as_callback(File.join(dir, "new.cpp"))
|
|
220
|
+
drain_idle
|
|
221
|
+
assert nb.lsp.equal?(lsp), "no LSP after Save As .cpp"
|
|
222
|
+
nb.view.show_context_menu(5, 5)
|
|
223
|
+
drain_idle
|
|
224
|
+
assert context_menu_labels(nb.view).include?("Jump to Definition")
|
|
225
|
+
ensure
|
|
226
|
+
vma.buffers.close_buffer(nb.id)
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
# The pnnfast.c case: a header in another dir, no compile flags -> clangd
|
|
232
|
+
# drops declarations using its types, so definition lookup finds nothing.
|
|
233
|
+
# After adding compile_flags.txt, :lsp_restart (new clangd, buffers
|
|
234
|
+
# reattached) makes it work, and the old clangd process exits.
|
|
235
|
+
def test_restart_picks_up_compile_flags
|
|
236
|
+
with_clangd do |_b, _lsp, _path, dir|
|
|
237
|
+
inc = File.join(dir, "inc")
|
|
238
|
+
Dir.mkdir(inc)
|
|
239
|
+
File.write(File.join(inc, "types.h"), "typedef struct { int n; } CODEBOOK;\ntypedef double dist_t;\n")
|
|
240
|
+
cpath = File.join(dir, "prog.c")
|
|
241
|
+
# Like pnnfast.c: more than clang's error limit (19) of unknown-type
|
|
242
|
+
# errors before calc(), so without the header clang stops parsing
|
|
243
|
+
# before reaching it.
|
|
244
|
+
decls = (1..25).map { |i| "dist_t v#{i};\n" }.join
|
|
245
|
+
File.write(cpath, "#include \"types.h\"\n#{decls}void calc(CODEBOOK *cb) { cb->n = 1; }\nint main() { CODEBOOK c; calc(&c); return 0; }\n")
|
|
246
|
+
File.write(File.join(dir, "compile_flags.txt"), "") # no -Iinc yet
|
|
247
|
+
cb = open_new_file(cpath)
|
|
248
|
+
begin
|
|
249
|
+
drain_idle
|
|
250
|
+
old = cb.lsp
|
|
251
|
+
assert old, "no LSP for prog.c"
|
|
252
|
+
call = [27, "int main() { CODEBOOK c; ".size]
|
|
253
|
+
sleep 1
|
|
254
|
+
assert_eq nil, old.get_definition(cpath, *call), "should fail without include path"
|
|
255
|
+
|
|
256
|
+
File.write(File.join(dir, "compile_flags.txt"), "-Iinc\n")
|
|
257
|
+
old_pid = old.pid
|
|
258
|
+
act :lsp_restart
|
|
259
|
+
assert cb.lsp && !cb.lsp.equal?(old), "buffer not reattached to a new server"
|
|
260
|
+
d = retry_until { cb.lsp.get_definition(cpath, *call) }
|
|
261
|
+
assert d, "no definition after restart"
|
|
262
|
+
assert_eq [File.realpath(cpath), 27], [File.realpath(d[0]), d[1]]
|
|
263
|
+
|
|
264
|
+
# the old clangd exits (and is reaped)
|
|
265
|
+
gone = false
|
|
266
|
+
30.times do
|
|
267
|
+
begin
|
|
268
|
+
Process.kill(0, old_pid)
|
|
269
|
+
rescue Errno::ESRCH
|
|
270
|
+
gone = true
|
|
271
|
+
break
|
|
272
|
+
end
|
|
273
|
+
sleep 0.1
|
|
274
|
+
end
|
|
275
|
+
assert gone, "old clangd (pid #{old_pid}) still running"
|
|
276
|
+
ensure
|
|
277
|
+
vma.buffers.close_buffer(cb.id)
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# LSP jump-to-definition test.
|
|
2
|
+
# Configures ruby-lsp internally — no custom.rb setup required.
|
|
3
|
+
# Skips gracefully if 'bundle exec ruby-lsp' is unavailable or times out.
|
|
4
|
+
#
|
|
5
|
+
# Run explicitly:
|
|
6
|
+
# ruby exe/run_tests.rb test_lsp_jump
|
|
7
|
+
|
|
8
|
+
class TestLspJumpToDefinition < VmaTest
|
|
9
|
+
REPO_ROOT = File.expand_path("../../", __FILE__)
|
|
10
|
+
|
|
11
|
+
# We jump from the `< VmaTest` reference in test_basic_editing.rb
|
|
12
|
+
# to the `class VmaTest` definition in test_framework.rb.
|
|
13
|
+
# Using a constant/class reference that ruby-lsp can resolve statically.
|
|
14
|
+
CALLER_FILE = File.join(REPO_ROOT, "tests/test_basic_editing.rb")
|
|
15
|
+
TARGET_FILE = File.join(REPO_ROOT, "lib/vimamsa/test_framework.rb")
|
|
16
|
+
|
|
17
|
+
def test_jump_to_definition
|
|
18
|
+
# langservp.rb is only loaded at startup when cnf.lsp.enabled — this
|
|
19
|
+
# test enables LSP after startup, so load it here.
|
|
20
|
+
require "vimamsa/langservp"
|
|
21
|
+
# Configure ruby-lsp for this test, pointing at the repo root so
|
|
22
|
+
# 'bundle exec ruby-lsp' can find the Gemfile and load its addons.
|
|
23
|
+
cnf.lsp.enabled = true
|
|
24
|
+
cnf.lsp.server.ruby_lsp = {
|
|
25
|
+
name: "ruby-lsp",
|
|
26
|
+
command: "bundle exec ruby-lsp",
|
|
27
|
+
languages: ["ruby"],
|
|
28
|
+
rooturi: "file://#{REPO_ROOT}",
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
# Reset any cached LSP instance so it re-initialises with the config above.
|
|
32
|
+
LangSrv.class_variable_get(:@@languages).delete("ruby")
|
|
33
|
+
|
|
34
|
+
# Open the caller file — this triggers LSP initialisation for "ruby".
|
|
35
|
+
open_new_file(CALLER_FILE)
|
|
36
|
+
drain_idle
|
|
37
|
+
|
|
38
|
+
unless vma.buf.lsp
|
|
39
|
+
puts " SKIP #{self.class}#test_jump_to_definition " \
|
|
40
|
+
"(ruby-lsp unavailable — is 'bundle exec ruby-lsp' installed?)"
|
|
41
|
+
return
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Locate `class TestBasicEditing < VmaTest` and position cursor on `VmaTest`.
|
|
45
|
+
caller_lines = File.readlines(CALLER_FILE)
|
|
46
|
+
caller_lnum = caller_lines.index { |l| l =~ /class\s+\w+\s*<\s*VmaTest\b/ }
|
|
47
|
+
assert !caller_lnum.nil?,
|
|
48
|
+
"Could not locate a '< VmaTest' class definition in #{File.basename(CALLER_FILE)}"
|
|
49
|
+
|
|
50
|
+
caller_col = caller_lines[caller_lnum].index("VmaTest")
|
|
51
|
+
assert !caller_col.nil?, "Could not locate 'VmaTest' token in the class definition line"
|
|
52
|
+
|
|
53
|
+
abs_pos = caller_lines[0...caller_lnum].sum(&:bytesize) + caller_col
|
|
54
|
+
act "buf.set_pos(#{abs_pos})"
|
|
55
|
+
|
|
56
|
+
# Find expected destination: `class VmaTest` in test_framework.rb.
|
|
57
|
+
target_lines = File.readlines(TARGET_FILE)
|
|
58
|
+
expected_lpos = target_lines.index { |l| l =~ /^class VmaTest\b/ }
|
|
59
|
+
assert !expected_lpos.nil?,
|
|
60
|
+
"Could not locate 'class VmaTest' in #{File.basename(TARGET_FILE)}"
|
|
61
|
+
|
|
62
|
+
# Give ruby-lsp a moment to process didOpen before the first request,
|
|
63
|
+
# then retry until we get a result (workspace indexing happens in background).
|
|
64
|
+
sleep 2
|
|
65
|
+
drain_idle
|
|
66
|
+
definition = nil
|
|
67
|
+
15.times do
|
|
68
|
+
definition = vma.buf.lsp.get_definition(CALLER_FILE, caller_lnum, caller_col)
|
|
69
|
+
break if definition
|
|
70
|
+
sleep 1
|
|
71
|
+
drain_idle
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
if definition.nil?
|
|
75
|
+
puts " SKIP #{self.class}#test_jump_to_definition " \
|
|
76
|
+
"(ruby-lsp returned no definition after 17 s — workspace still indexing?)"
|
|
77
|
+
return
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
assert_eq File.expand_path(TARGET_FILE), definition[0],
|
|
81
|
+
"Expected definition in #{File.basename(TARGET_FILE)}, " \
|
|
82
|
+
"got #{File.basename(definition[0].to_s)}"
|
|
83
|
+
|
|
84
|
+
assert_eq expected_lpos, definition[1] - 1,
|
|
85
|
+
"Expected line #{expected_lpos} (0-based), got #{definition[1] - 1}"
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require "tmpdir"
|
|
2
|
+
|
|
3
|
+
# LangSrv#lsp_character converts Ruby character columns to the units of the
|
|
4
|
+
# server's position encoding. Needs no language server.
|
|
5
|
+
class TestLspPositionEncoding < VmaTest
|
|
6
|
+
LINE = "s = \"ää😀\"; x\n" # "x" is at char 11
|
|
7
|
+
|
|
8
|
+
def with_lsp(encoding)
|
|
9
|
+
require "vimamsa/langservp"
|
|
10
|
+
lsp = LangSrv.allocate
|
|
11
|
+
lsp.instance_variable_set(:@position_encoding, encoding)
|
|
12
|
+
Dir.mktmpdir do |dir|
|
|
13
|
+
path = File.join(dir, "a.c")
|
|
14
|
+
File.write(path, "first\n#{LINE}")
|
|
15
|
+
yield lsp, path
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_utf8_counts_bytes
|
|
20
|
+
with_lsp("utf-8") { |lsp, path| assert_eq 16, lsp.lsp_character(path, 1, 11) }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_utf16_counts_code_units
|
|
24
|
+
with_lsp("utf-16") { |lsp, path| assert_eq 12, lsp.lsp_character(path, 1, 11) }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_utf32_counts_chars
|
|
28
|
+
with_lsp("utf-32") { |lsp, path| assert_eq 11, lsp.lsp_character(path, 1, 11) }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_ascii_prefix_unchanged
|
|
32
|
+
with_lsp("utf-8") { |lsp, path| assert_eq 3, lsp.lsp_character(path, 1, 3) }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_file_uri_and_open_buffer
|
|
36
|
+
with_lsp("utf-8") do |lsp, path|
|
|
37
|
+
b = open_new_file(path)
|
|
38
|
+
begin
|
|
39
|
+
# The open buffer, not the file on disk, is what the server sees.
|
|
40
|
+
b.set_pos(b.line_range(1, 1).begin)
|
|
41
|
+
b.insert_txt("ö")
|
|
42
|
+
uri = lsp.file_uri(path)
|
|
43
|
+
assert_eq 18, lsp.lsp_character(uri, 1, 12)
|
|
44
|
+
ensure
|
|
45
|
+
vma.buffers.close_buffer(b.id)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# LSP documentSymbol test — exercises LangSrv#document_functions (and the
|
|
2
|
+
# shared request_document_symbols scaffolding it now delegates to).
|
|
3
|
+
# Skips gracefully if 'bundle exec ruby-lsp' is unavailable or times out.
|
|
4
|
+
#
|
|
5
|
+
# Run explicitly:
|
|
6
|
+
# ruby exe/run_tests.rb test_lsp_symbols
|
|
7
|
+
|
|
8
|
+
class TestLspSymbols < VmaTest
|
|
9
|
+
REPO_ROOT = File.expand_path("../../", __FILE__)
|
|
10
|
+
# test_framework.rb defines VmaTest with clearly named methods (run_all, etc.)
|
|
11
|
+
SYMBOL_FILE = File.join(REPO_ROOT, "lib/vimamsa/test_framework.rb")
|
|
12
|
+
|
|
13
|
+
def configure_ruby_lsp
|
|
14
|
+
require "vimamsa/langservp"
|
|
15
|
+
cnf.lsp.enabled = true
|
|
16
|
+
cnf.lsp.server.ruby_lsp = {
|
|
17
|
+
name: "ruby-lsp",
|
|
18
|
+
command: "bundle exec ruby-lsp",
|
|
19
|
+
languages: ["ruby"],
|
|
20
|
+
rooturi: "file://#{REPO_ROOT}",
|
|
21
|
+
}
|
|
22
|
+
LangSrv.class_variable_get(:@@languages).delete("ruby")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_document_functions_lists_methods
|
|
26
|
+
configure_ruby_lsp
|
|
27
|
+
open_new_file(SYMBOL_FILE)
|
|
28
|
+
drain_idle
|
|
29
|
+
|
|
30
|
+
lsp = vma.buf.lsp
|
|
31
|
+
unless lsp
|
|
32
|
+
puts " SKIP #{self.class}#test_document_functions_lists_methods " \
|
|
33
|
+
"(ruby-lsp unavailable — is 'bundle exec ruby-lsp' installed?)"
|
|
34
|
+
return
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# documentSymbol is per-file; give didOpen a moment, then retry.
|
|
38
|
+
sleep 1
|
|
39
|
+
drain_idle
|
|
40
|
+
funcs = nil
|
|
41
|
+
15.times do
|
|
42
|
+
funcs = lsp.document_functions(SYMBOL_FILE)
|
|
43
|
+
break if funcs && !funcs.empty?
|
|
44
|
+
sleep 1
|
|
45
|
+
drain_idle
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
if funcs.nil? || funcs.empty?
|
|
49
|
+
puts " SKIP #{self.class}#test_document_functions_lists_methods " \
|
|
50
|
+
"(ruby-lsp returned no symbols — still indexing?)"
|
|
51
|
+
return
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Shape: [{ name:, line: }, ...] with 1-based lines.
|
|
55
|
+
assert(funcs.all? { |f| f.key?(:name) && f.key?(:line) },
|
|
56
|
+
"each entry should have :name and :line")
|
|
57
|
+
names = funcs.map { |f| f[:name] }
|
|
58
|
+
assert(names.include?("run_all"),
|
|
59
|
+
"expected method 'run_all' among symbols, got: #{names.first(20).inspect}")
|
|
60
|
+
|
|
61
|
+
# Cross-check the reported line against the file (1-based).
|
|
62
|
+
entry = funcs.find { |f| f[:name] == "run_all" }
|
|
63
|
+
file_lines = File.readlines(SYMBOL_FILE)
|
|
64
|
+
assert(entry[:line] > 0, "run_all should have a real line number")
|
|
65
|
+
assert(file_lines[entry[:line] - 1] =~ /def\s+run_all\b/,
|
|
66
|
+
"line #{entry[:line]} should hold 'def run_all', got: #{file_lines[entry[:line] - 1].inspect}")
|
|
67
|
+
end
|
|
68
|
+
end
|
data/tests/test_macro.rb
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
class TestMacro < VmaTest
|
|
2
|
+
LINE = "I am 1234 years and 56 days"
|
|
3
|
+
EDITED = "I am 34 years and 56 days"
|
|
4
|
+
|
|
5
|
+
# Buffer with the first +n_edited+ lines edited by the macro.
|
|
6
|
+
def expected_buf(n_edited)
|
|
7
|
+
([EDITED] * n_edited + [LINE] * (5 - n_edited)).join("\n") + "\n"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Fill the buffer with +n+ copies of +line+, cursor at the start.
|
|
11
|
+
def set_lines(line, n)
|
|
12
|
+
act "buf.insert_txt(#{([line] * n).join("\n").inspect})"
|
|
13
|
+
act :jump_to_start_of_buffer
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def recorded(slot)
|
|
17
|
+
vma.macro.recorded_macros[slot]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Record a macro that edits one line and moves to the next, then run it:
|
|
21
|
+
# w -> start of "1234" (col 5)
|
|
22
|
+
# x x -> delete "12", leaving "34" (col 5)
|
|
23
|
+
# b -> start of "am" (col 2)
|
|
24
|
+
# h -> one char left (col 1)
|
|
25
|
+
# j -> next line, same column (col 1)
|
|
26
|
+
def test_run_recorded_macro
|
|
27
|
+
set_lines(LINE, 5)
|
|
28
|
+
act "buf.set_pos(2)" # third character of the first line ("a")
|
|
29
|
+
assert_pos 0, 2
|
|
30
|
+
|
|
31
|
+
keys "q a" # start recording into slot "a"
|
|
32
|
+
keys "w x x b h j"
|
|
33
|
+
keys "q" # end recording
|
|
34
|
+
assert_buf expected_buf(1)
|
|
35
|
+
assert_pos 1, 1
|
|
36
|
+
|
|
37
|
+
# Run the macro on lines 1..3; the last line must stay untouched.
|
|
38
|
+
(1..3).each do |lpos|
|
|
39
|
+
keys "l" # back to the third character
|
|
40
|
+
assert_pos lpos, 2
|
|
41
|
+
keys "@ a"
|
|
42
|
+
assert_buf expected_buf(lpos + 1), "buffer mismatch after running macro on line #{lpos}"
|
|
43
|
+
assert_pos lpos + 1, 1
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Text typed in insert mode is part of the macro and is replayed.
|
|
48
|
+
def test_macro_with_insert_mode_text
|
|
49
|
+
set_lines("item1", 3)
|
|
50
|
+
keys "q a A o k esc j q"
|
|
51
|
+
assert_buf "item1ok\nitem1\nitem1\n"
|
|
52
|
+
assert_mode :command
|
|
53
|
+
|
|
54
|
+
keys "@ a"
|
|
55
|
+
keys "@ a"
|
|
56
|
+
assert_buf "item1ok\nitem1ok\nitem1ok\n"
|
|
57
|
+
assert_mode :command
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# A count before @ runs the macro that many times.
|
|
61
|
+
def test_macro_with_count
|
|
62
|
+
set_lines("abc", 5)
|
|
63
|
+
keys "q a 0 x j q"
|
|
64
|
+
assert_buf "bc\nabc\nabc\nabc\nabc\n"
|
|
65
|
+
|
|
66
|
+
keys "3 @ a"
|
|
67
|
+
assert_buf "bc\nbc\nbc\nbc\nabc\n"
|
|
68
|
+
assert_pos 4, 0
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# M runs the most recently recorded macro.
|
|
72
|
+
def test_run_last_macro
|
|
73
|
+
set_lines("abc", 3)
|
|
74
|
+
keys "q b 0 x j q"
|
|
75
|
+
keys "M"
|
|
76
|
+
assert_buf "bc\nbc\nabc\n"
|
|
77
|
+
assert_pos 2, 0
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Macros in different slots don't affect each other.
|
|
81
|
+
def test_slots_are_independent
|
|
82
|
+
set_lines("abcd", 4)
|
|
83
|
+
keys "q a 0 x j q" # delete the first char
|
|
84
|
+
keys "q b 0 l x j q" # delete the second char
|
|
85
|
+
keys "@ a"
|
|
86
|
+
keys "@ b"
|
|
87
|
+
assert_buf "bcd\nacd\nbcd\nacd\n"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Recording into a slot again replaces the old macro.
|
|
91
|
+
def test_rerecording_replaces_macro
|
|
92
|
+
set_lines("abcd", 4)
|
|
93
|
+
keys "q a 0 x j q" # delete the first char
|
|
94
|
+
keys "q a 0 l x j q" # now: delete the second char
|
|
95
|
+
keys "@ a"
|
|
96
|
+
assert_buf "bcd\nacd\nacd\nabcd\n"
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Running a slot with nothing recorded changes nothing.
|
|
100
|
+
def test_run_empty_slot_is_noop
|
|
101
|
+
vma.macro.recorded_macros.delete("z")
|
|
102
|
+
set_lines("abc", 2)
|
|
103
|
+
act "buf.set_pos(1)"
|
|
104
|
+
keys "@ z"
|
|
105
|
+
assert_buf "abc\nabc\n"
|
|
106
|
+
assert_pos 0, 1
|
|
107
|
+
assert_mode :command
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Every motion is recorded, so the replay ends where the recording did.
|
|
111
|
+
# (Backward motions returned false from set_pos and were silently dropped.)
|
|
112
|
+
def test_motions_replay_like_recording
|
|
113
|
+
set_lines("ab cd ef", 3)
|
|
114
|
+
act "buf.set_pos(12)" # line 1, "cd"
|
|
115
|
+
assert_pos 1, 3
|
|
116
|
+
|
|
117
|
+
keys "q a 0 $ b e w h l j k q"
|
|
118
|
+
assert_eq 9, recorded("a").size, "not every motion was recorded: #{recorded("a").inspect}"
|
|
119
|
+
end_lpos, end_cpos = buf.lpos, buf.cpos
|
|
120
|
+
|
|
121
|
+
act "buf.set_pos(12)"
|
|
122
|
+
keys "@ a"
|
|
123
|
+
assert_pos end_lpos, end_cpos
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# @ is ignored while recording: nothing runs and nothing is recorded.
|
|
127
|
+
def test_run_macro_while_recording_is_ignored
|
|
128
|
+
set_lines("abc", 3)
|
|
129
|
+
keys "q a 0 x j q"
|
|
130
|
+
assert_buf "bc\nabc\nabc\n"
|
|
131
|
+
|
|
132
|
+
keys "q b @ a j q"
|
|
133
|
+
assert_buf "bc\nabc\nabc\n"
|
|
134
|
+
assert_pos 2, 0
|
|
135
|
+
assert_eq [:forward_line], recorded("b")
|
|
136
|
+
end
|
|
137
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
require "tmpdir"
|
|
2
|
+
|
|
3
|
+
# markdown.lang maps its tokens to def:heading, def:inline-code, def:link-text,
|
|
4
|
+
# ... which have no fallback in def.lang. The generated overlay
|
|
5
|
+
# (markup_overlay_styles in gui_settings.rb) adds them for schemes that lack
|
|
6
|
+
# them, so markdown isn't drawn as plain text with the bundled schemes.
|
|
7
|
+
class TestMarkdownHighlight < VmaTest
|
|
8
|
+
def scheme(id)
|
|
9
|
+
ssm = GtkSource::StyleSchemeManager.new
|
|
10
|
+
ssm.set_search_path(ssm.search_path << ppath("styles/"))
|
|
11
|
+
ssm.get_scheme(id)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def styled?(st)
|
|
15
|
+
!st.nil? && ((st.foreground || "") != "" || st.bold? || st.italic? || (st.underline || "none") != "none")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_overlay_styles_markdown_on_default_scheme
|
|
19
|
+
old = cnf.style_scheme!
|
|
20
|
+
cnf.style_scheme = "molokai_edit"
|
|
21
|
+
sty = load_vimamsa_scheme
|
|
22
|
+
%w[def:heading def:inline-code def:link-text def:strong-emphasis def:list-marker].each { |n|
|
|
23
|
+
assert styled?(sty.get_style(n)), "#{n} has no style on molokai_edit"
|
|
24
|
+
}
|
|
25
|
+
# Colors come from the scheme's own styles
|
|
26
|
+
assert_eq scheme("molokai_edit").get_style("def:string").foreground,
|
|
27
|
+
sty.get_style("def:inline-code").foreground
|
|
28
|
+
assert sty.get_style("def:heading").bold?
|
|
29
|
+
ensure
|
|
30
|
+
cnf.style_scheme = old
|
|
31
|
+
gui_refresh_style_scheme
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_scheme_with_markup_styles_is_left_alone
|
|
35
|
+
sty = scheme("Adwaita")
|
|
36
|
+
skip "no Adwaita scheme" if sty.nil?
|
|
37
|
+
out = markup_overlay_styles(sty)
|
|
38
|
+
added = out.scan(/name="([^"]+)"/).flatten
|
|
39
|
+
defined = MARKUP_OVERLAY_STYLES.keys.select { |n| sty.get_style(n) }
|
|
40
|
+
assert defined.include?("def:heading"), "Adwaita should define def:heading"
|
|
41
|
+
assert_eq [], added & defined, "overlay overrides styles the scheme has"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_md_file_gets_markdown_language
|
|
45
|
+
Dir.mktmpdir { |dir|
|
|
46
|
+
path = "#{dir}/x.md"
|
|
47
|
+
File.write(path, "# Title\n\nSome `code` and a [link](http://example.com).\n")
|
|
48
|
+
b = open_new_file(path)
|
|
49
|
+
drain_idle
|
|
50
|
+
begin
|
|
51
|
+
assert_eq "markdown", b.view.buffer.language&.id
|
|
52
|
+
ensure
|
|
53
|
+
vma.buffers.close_buffer(b.id)
|
|
54
|
+
end
|
|
55
|
+
}
|
|
56
|
+
end
|
|
57
|
+
end
|