Vim - Un plugin pour markdown - partie 8
On continue d’implémenter la fonctionnalité commencée hier en testant deux cas exceptionnels, toujours à l’aide de Vader.
Revoici le fichier de test d’hier:
Given (some text):
abc def ghi jkl mno
Execute (starting in middle of a word):
execute "normal! fe"
QuickMarkdownItalic
Expect (2nd word in italic):
abc *def* ghi jkl mnoJe vais ajouter deux tests. L’un pour voir ce qu’il se passe quand le curseur se trouve au début d’un mot, et idem pour la fin d’un mot:
Given (some text):
abc def ghi jkl mno
Execute (starting in middle of a word):
execute "normal! fe"
QuickMarkdownItalic
Expect (2nd word in italic):
abc *def* ghi jkl mno
Execute (starting at beginning of a word):
execute "normal! fd"
QuickMarkdownItalic
Expect (2nd word in italic):
abc *def* ghi jkl mno
Execute (starting at the end of a word):
execute "normal! ff"
QuickMarkdownItalic
Expect (2nd word in italic):
abc *def* ghi jkl mnoEt avec l’implémentation de la dernière fois:
function! quickmarkdown#italic()
execute "normal! bi*\<Esc>ea*\<Esc>"
endfunction… le test où le curseur se trouve au début d’un mot échoue misérablement.
Pour le faire passer, on doit d’abord déplacer le curseur d’un cran vers la droite:
function! quickmarkdown#italic()
execute "normal! lbi*\<Esc>ea*\<Esc>"
endfunctionLa prochaine fois on continue avec d’autres cas exceptionnels.
À demain.
/ / / / / / / / / /