From 8aeb780d67b08001a2b6b82006ecfcc6cb38cb8e Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Wed, 30 Jul 2025 16:26:17 -0400 Subject: [PATCH 1/3] Create tests for bugs reported about empty lines in strings vs indentation (#159) Those are all of the examples that match the reported indentation errors. The very strange thing is that all of the new tests fail, but they fail differently in vader than how they do in an interactive (n)vim session. The result that we get in those tests is usually that the string contents get wrongly moved to fit indentation. However, when I run the indentation command in the editor, the string contents don't change but things afterwards get indented at the wrong level. I'm not sure why the tests don't behave in the same way. --- test/indent/comments_strings.vader | 96 ++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/test/indent/comments_strings.vader b/test/indent/comments_strings.vader index 3ce6c07..ec704c6 100644 --- a/test/indent/comments_strings.vader +++ b/test/indent/comments_strings.vader @@ -63,3 +63,99 @@ Do (New line): Expect puppet (indent stays the same): $baz = '[#' $qux + +------------------------------------------------------------------------------- +Given puppet (empty line in heredoc): + class blah { + $value = @(HERE) + empty line in here + + should not affect indentation after here + | HERE + + file { '/tmp/somefile': + ensure => 'present', + } + } + +Do (full text indent with '='): + gg=G + +Expect puppet (indentation shouldn't move): + class blah { + $value = @(HERE) + empty line in here + + should not affect indentation after here + | HERE + + file { '/tmp/somefile': + ensure => 'present', + } + } + +------------------------------------------------------------------------------- +Given puppet (empty line in string): + class blah { + $value = 'empty line in here + + should not affect indentation after here' + + file { '/tmp/somefile': + ensure => 'present', + } + } + +Do (full text indent with '='): + gg=G + +Expect puppet (indentation shouldn't move): + class blah { + $value = 'empty line in here + + should not affect indentation after here' + + file { '/tmp/somefile': + ensure => 'present', + } + } + +------------------------------------------------------------------------------- +Given puppet (line in string with only spaces): + class blah { + $value = 'next line contains spaces + + and should stay the same' + } + +Do (full text indent with '='): + gg=G + +Expect puppet (spaces within string should remain there): + class blah { + $value = 'next line contains spaces + + and should stay the same' + } + +------------------------------------------------------------------------------- +Given puppet (line in heredoc with only spaces): + class blah { + $value = @(HERE) + next line contains spaces + + and should stay the same + | HERE + } + +Do (full text indent with '='): + gg=G + +Expect puppet (spaces within string should remain there): + class blah { + $value = @(HERE) + next line contains spaces + + and should stay the same + | HERE + } From bfdc5a1898dbf230d3d7bce4c523e4b17c38c6b1 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Mon, 4 Aug 2025 09:34:40 -0400 Subject: [PATCH 2/3] Update test/indent/comments_strings.vader Try and wait for syntax to be fully evaluated before running the indexing command Co-authored-by: Alexander Fisher --- test/indent/comments_strings.vader | 1 + 1 file changed, 1 insertion(+) diff --git a/test/indent/comments_strings.vader b/test/indent/comments_strings.vader index ec704c6..8cc573a 100644 --- a/test/indent/comments_strings.vader +++ b/test/indent/comments_strings.vader @@ -79,6 +79,7 @@ Given puppet (empty line in heredoc): } Do (full text indent with '='): + :syntax sync fromstart gg=G Expect puppet (indentation shouldn't move): From f8b7730275014800e91b48df4a88a5733a619f1d Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Mon, 4 Aug 2025 09:43:53 -0400 Subject: [PATCH 3/3] Implement the same fix as the previous commit for all new tests Things really did change with the addition of the wait for the syntax. Apparently as @alexjfisher said, the format function needs its calls to get the correct syntax ID so we need the syntax file to be fully loaded before trying to format things. --- test/indent/comments_strings.vader | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/indent/comments_strings.vader b/test/indent/comments_strings.vader index 8cc573a..10fb6b2 100644 --- a/test/indent/comments_strings.vader +++ b/test/indent/comments_strings.vader @@ -108,6 +108,7 @@ Given puppet (empty line in string): } Do (full text indent with '='): + :syntax sync fromstart gg=G Expect puppet (indentation shouldn't move): @@ -130,6 +131,7 @@ Given puppet (line in string with only spaces): } Do (full text indent with '='): + :syntax sync fromstart gg=G Expect puppet (spaces within string should remain there): @@ -150,6 +152,7 @@ Given puppet (line in heredoc with only spaces): } Do (full text indent with '='): + :syntax sync fromstart gg=G Expect puppet (spaces within string should remain there):