File: link_anchor.vader

package info (click to toggle)
vim-vimwiki 2024.01.24-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,692 kB
  • sloc: sh: 313; makefile: 2
file content (440 lines) | stat: -rw-r--r-- 8,154 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
# Link internal to a file
#
# See: generate_toc.vim
#
# See issue #666 for anchor support (then internal links)
# Preambule set file onces and for all {{{1
# Otherwise the bash script is freezing


### Wiki {{{1
###############


### Markdown {{{1
###############


Given vimwiki (a):
  a

Execute (Set filename wiki_test.md):
  file wiki_test.md

Expect (a):
  a


Given vimwiki (VimwikiTOC with link and number {{{1):
  [link1](#i-v-p-741528)
  [link2](#i-v-p-741528-2)

  # I [V p](h) (7.415.28)

  # I [V p](h) 741.528

Execute (Set syntax markdown):
  call SetSyntax('markdown')

Expect('No change'):
  [link1](#i-v-p-741528)
  [link2](#i-v-p-741528-2)

  # I [V p](h) (7.415.28)

  # I [V p](h) 741.528

Do (Enter link):
  gg\<Cr>
  A__HERE1__\<Esc>
  ggj\<Cr>
  A__HERE2__\<Esc>
  :AssertEqual 'wiki_test.md', expand('%')\<Cr>

Expect(Some suffix added after headings):
  [link1](#i-v-p-741528)
  [link2](#i-v-p-741528-2)

  # I [V p](h) (7.415.28)__HERE1__

  # I [V p](h) 741.528__HERE2__

Given vimwiki (VimwikiTOC is broken against headers with link #182 {{{1):
  [A link B](#a-link-b)
  [tlink](#tlink)
  [7.4.1528](#741528)
  [link (333)](#link-333)

  # A [link](anything here) B

  # t[link](anything here)

  ## 7.4.1528

  #### [link]() (333)


Execute (Set syntax markdown):
  call SetSyntax('markdown')


Do (Enter link):
  gg\<Cr>
  A__HERE1__\<Esc>
  ggj\<Cr>
  A__HERE2__\<Esc>
  ggjj\<Cr>
  A__HERE3__\<Esc>
  ggjjj\<Cr>
  A__HERE4__\<Esc>
  :AssertEqual 'markdown', vimwiki#vars#get_wikilocal('syntax')\<Cr>


Expect vimwiki (Good anchor with link navigation):
  [A link B](#a-link-b)
  [tlink](#tlink)
  [7.4.1528](#741528)
  [link (333)](#link-333)

  # A [link](anything here) B__HERE1__

  # t[link](anything here)__HERE2__

  ## 7.4.1528__HERE3__

  #### [link]() (333)__HERE4__



# Link to anchor in SetExt {{{1
# Like that
# -----
# Issue: #209

Given vimwiki (Anchor SetExt):
  [jump](#frst-one)

  F!rst    One
  =========

Execute (Set filename wiki_test.md):
  call SetSyntax('markdown')

Do (Enter link):
  \<Cr>
  A__HERE__\<Esc>

Expect (Cursor jumped SetExt):
  [jump](#frst-one)

  F!rst    One__HERE__
  =========

Given vimwiki (Bad Anchor SetExt):
  [jump](#frst-one)

  F!rst    One

Execute (Set filename wiki_test.md):
  call SetSyntax('markdown')

Do (Enter link):
  \<Cr>
  A__HERE__\<Esc>

Expect (Cursor stayed (not jumped) SetExt):
  [jump](#frst-one)__HERE__

  F!rst    One

# Link to anchor with spaces {{{1
# PR #840
# Issues: #831

Given vimwiki (Internal links zith spaces):
  [Any ! apparent name @#$](#basic-heading-many-spaces)
  One line here

  ##    Basic  HeAding Many   SpacES

  One line here

Execute (Set filename wiki_test.md):
  call SetSyntax('markdown')

Do (Enter link):
  \<Cr>
  A__HERE__\<Esc>

Expect (Cursor at heading position):
  [Any ! apparent name @#$](#basic-heading-many-spaces)
  One line here

  ##    Basic  HeAding Many   SpacES__HERE__

  One line here

Execute (Clear wiki jumps (alias: prev_links)):
  call vimwiki#vars#set_bufferlocal('prev_links', [])


# Before {{{1

Given vimwiki (Internal links + one link to filenew):
  # Contents

    - [Test1](#Test1)
    - [Test2](#Test2)

  # Test1

    - [Test1](#Test1)
    - [Test2](#Test2)
    - [filenew](filenew)

  # Test2

    - [Test1](#Test1)
    - [Test2](#Test2)
    - [filenew](filenew)

Execute (Set filename wiki_test.md):
  call SetSyntax('markdown')

Execute (Set filename wiki_test.md):
  file wiki_test.md

Do (Navigate with <Tab>):
  A more Contents\<Esc>
  \<Tab>
  \<Enter>
  A more Test1\<Esc>
  \<Tab>
  \<Tab>
  \<Enter>
  A more Test2\<Esc>
  :AssertEqual 'wiki_test.md', expand('%')\<Cr>

Expect (Content added to titles):
  # Contents more Contents

    - [Test1](#Test1)
    - [Test2](#Test2)

  # Test1 more Test1

    - [Test1](#Test1)
    - [Test2](#Test2)
    - [filenew](filenew)

  # Test2 more Test2

    - [Test1](#Test1)
    - [Test2](#Test2)
    - [filenew](filenew)

Do (Navigate with <Tab> and <Enter> and come back with <Bs>):
  \<Tab>
  \<Enter>
# Cursor at Test1
  \<Tab>
  \<Tab>
  \<Enter>
# Cursor at Test2
  \<Tab>
  \<Tab>
  \<Tab>
# Debugging
  :redir @a\<Cr>
  :nmap <Bs>\<Cr>
  :redir END\<Cr>
# :fixdel\<Cr>
  :AssertEqual 'wiki_test.md', expand('%')\<Cr>
#  :AssertEqual 'toto', @a\<Cr>
# Cursor at Test2/filenew
  A not yet\<Esc>\<Esc>
# Debug
  :Log 'Debugging 1, cursor position list'\<Cr>
  :Log vimwiki#vars#get_bufferlocal('prev_links')\<Cr>
#  :VimwikiGoBackLink\<Cr>
#  :call vimwiki#base#go_back_link()\<Cr>
  \<Bs>
  :Log 'Debugging 2, cursor position list'\<Cr>
  :Log vimwiki#vars#get_bufferlocal('prev_links')\<Cr>
# Cursor at Test1/test2
  A near Test1/test2
  \<Esc>
  \<Bs>
# Cursor at Contents/test1
  A near Contents/test1
  \<Esc>

Expect (Vimwiki links):
  # Contents

    - [Test1](#Test1) near Contents/test1
    - [Test2](#Test2)

  # Test1

    - [Test1](#Test1)
    - [Test2](#Test2) near Test1/test2
    - [filenew](filenew)

  # Test2

    - [Test1](#Test1)
    - [Test2](#Test2)
    - [filenew](filenew) not yet


###################################
###################################
###################################
###################################
# Commented out as butsetvar of the var prev_links is removing the list info at change of file for old Vim




#Do (Navigate with <Tab> comeback with <Bs> from filenew):
#  \<Tab>
#  A first shot\<Esc>
#  0\<Tab>
## Cursor at Contents/test1
#  \<Cr>
#  \<Tab>
#  \<Tab>
#  A first shot\<Esc>
#  0\<Tab>
## Cursor at Test1/test2
#  \<Cr>
#  G
## Cursor at Test2/filenew
#  A first shot\<Esc>
#  0\<Tab>
## Cursor at Test2/filenew
#  \<Cr>
## Cursor in filenew (a new file)
#  A anything in filenew: empirically it does not count\<Esc>
## Debug back
#  :Log 'Debugging back 1, cursor position list'\<Cr>
#  :Log vimwiki#vars#get_bufferlocal('prev_links')\<Cr>
#  :Log expand('%:p')\<Cr>
#  :Log expand('/tmp/vader_wiki/testplugin/wiki_test.md')\<Cr>
#  :Log filereadable('/tmp/vader_wiki/testplugin/wiki_test.md')\<Cr>
#  \<Bs>
#  :Log 'Debugging back 2, cursor position list'\<Cr>
#  :Log vimwiki#vars#get_bufferlocal('prev_links')\<Cr>
#  :Log expand('%')\<Cr>
## Cursor at Test2/filenew
#  \<Bs>
## Cursor at Test1/test2
#  \<Bs>
## Cursor at Contents/test1
#  A second shot
#
#Expect (Just Contents/test1 got the second shot):
#  # Contents
#
#    - [Test1](#Test1) first shot second shot
#    - [Test2](#Test2)
#
#  # Test1
#
#    - [Test1](#Test1)
#    - [Test2](#Test2) first shot
#    - [filenew](filenew)
#
#  # Test2
#
#    - [Test1](#Test1)
#    - [Test2](#Test2)
#    - [filenew](filenew) first shot

Execute (Delete filenew buffer):
  call DeleteFile('/testplugin/filenew.md')

Do (Navigate with <Tab> comeback with <Bs> too far):
  \<Tab>
# Cursor at Contents/test1
  \<Cr>
  \<Tab>
  \<Tab>
# Cursor at Test1/test2
  \<Cr>
  \<Tab>
# Cursor at Test2/test1
  \<Cr>
  \<Tab>
  \<Tab>
# Cursor at Test1/test2
  \<Cr>
  A first test2\<Esc>
  \<Tab>
# Cursor at Test2/test1
  \<Cr>
  A first test1\<Esc>
# Back
  \<Bs>
# Cursor at Test2/test1
  A second test2/test1\<Esc>
  \<Bs>
# Cursor at Test1/test2
  A second test1/test2\<Esc>
  \<Bs>
# Cursor at Test2/test1
  \<Bs>
# Cursor at Test1/test2
  \<Bs>
# Cursor at Contents/test1
# Finished
  \<Bs>
  \<Bs>
  \<Bs>
  \<Bs>
  A 1\<Esc>
  \<Bs>
  A 2\<Esc>
  \<Bs>
  A 3\<Esc>
  \<Bs>
  A 4\<Esc>

Expect (After too many <Bs>, cursor stays at the first <Cr> spot in first file: Contents/test1):
  # Contents

    - [Test1](#Test1) 1 2 3 4
    - [Test2](#Test2)

  # Test1 first test1

    - [Test1](#Test1)
    - [Test2](#Test2) second test1/test2
    - [filenew](filenew)

  # Test2 first test2

    - [Test1](#Test1) second test2/test1
    - [Test2](#Test2)
    - [filenew](filenew)

Given vimwiki (link to self):
  - [Bad link](Very bad.html)
  - [My own file](wiki_test)
  - [Test1](#Test1)
  - [Test2](#Test2)

Do (Follow link to self and append chars):
  \<Tab>
  \<Tab>
  \<Cr>
  a this_is_18_chars \<Esc>

Expect (Some chars appended at self link):
  - [Bad link](Very bad.html)
  - [ this_is_18_chars My own file](wiki_test)
  - [Test1](#Test1)
  - [Test2](#Test2)

# vim: foldmethod=marker foldlevel=30 sw=2