From 5af29b025419fa3df9f82b99478f64e6e13855d4 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 13 Oct 2016 20:10:41 +0100 Subject: [PATCH] Fix python comment copy logic in python.kak And introduce the first unit test that sources bundled support scripts. Fixes #860 --- rc/core/python.kak | 4 ++-- share/kak/rc | 1 + test/regression/860-python-incorrect-commenting/cmd | 1 + test/regression/860-python-incorrect-commenting/in | 2 ++ test/regression/860-python-incorrect-commenting/out | 2 ++ test/regression/860-python-incorrect-commenting/rc | 4 ++++ 6 files changed, 12 insertions(+), 2 deletions(-) create mode 120000 share/kak/rc create mode 100644 test/regression/860-python-incorrect-commenting/cmd create mode 100644 test/regression/860-python-incorrect-commenting/in create mode 100644 test/regression/860-python-incorrect-commenting/out create mode 100644 test/regression/860-python-incorrect-commenting/rc diff --git a/rc/core/python.kak b/rc/core/python.kak index d50795046..69da651a7 100644 --- a/rc/core/python.kak +++ b/rc/core/python.kak @@ -60,8 +60,8 @@ def -hidden _python_indent_on_new_line %{ # cleanup trailing whitespaces from previous line try %{ exec -draft k s \h+$ d } # copy '#' comment prefix and following white spaces - try %{ exec -draft k x s ^\h*\K#\h* y j p } - # indent after : + try %{ exec -draft k x s ^\h*#\h* y jgh P } + # indent after line ending with : try %{ exec -draft k x :$ j } } } diff --git a/share/kak/rc b/share/kak/rc new file mode 120000 index 000000000..f8fbe638b --- /dev/null +++ b/share/kak/rc @@ -0,0 +1 @@ +../../rc \ No newline at end of file diff --git a/test/regression/860-python-incorrect-commenting/cmd b/test/regression/860-python-incorrect-commenting/cmd new file mode 100644 index 000000000..a5ac41383 --- /dev/null +++ b/test/regression/860-python-incorrect-commenting/cmd @@ -0,0 +1 @@ +welc diff --git a/test/regression/860-python-incorrect-commenting/in b/test/regression/860-python-incorrect-commenting/in new file mode 100644 index 000000000..be851b25e --- /dev/null +++ b/test/regression/860-python-incorrect-commenting/in @@ -0,0 +1,2 @@ +# comment +if haha diff --git a/test/regression/860-python-incorrect-commenting/out b/test/regression/860-python-incorrect-commenting/out new file mode 100644 index 000000000..91b4dc7c2 --- /dev/null +++ b/test/regression/860-python-incorrect-commenting/out @@ -0,0 +1,2 @@ +# comment +# if haha diff --git a/test/regression/860-python-incorrect-commenting/rc b/test/regression/860-python-incorrect-commenting/rc new file mode 100644 index 000000000..4eec08e13 --- /dev/null +++ b/test/regression/860-python-incorrect-commenting/rc @@ -0,0 +1,4 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/core/formatter.kak" +source "%val{runtime}/rc/core/python.kak" +set buffer filetype python