From f5ae0ac83ad43edc23361ca58fb483fb53f79e6a Mon Sep 17 00:00:00 2001 From: Mateo Gjika <104777599+mateoxh@users.noreply.github.com> Date: Sat, 1 Mar 2025 19:42:55 +0100 Subject: [PATCH 1/2] Fix case of multiple 'do' blocks on the same line --- indent/haskell.vim | 5 +++-- test/do/double_do.in.hs | 3 +++ test/do/double_do.out.hs | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 test/do/double_do.in.hs create mode 100644 test/do/double_do.out.hs diff --git a/indent/haskell.vim b/indent/haskell.vim index 1cb8435..82915ea 100644 --- a/indent/haskell.vim +++ b/indent/haskell.vim @@ -2,7 +2,7 @@ " Filename: indent/haskell.vim " Author: itchyny " License: MIT License -" Last Change: 2024/11/01 20:51:18. +" Last Change: 2025/03/01 19:41:22. " ============================================================================= if exists('b:did_indent') @@ -128,7 +128,8 @@ function! GetHaskellIndent() abort endif if nonblankline =~# '\v\s*[[:alnum:](]' - return match(nonblankline, '\v\s*\zs\S') + let i = strridx(nonblankline, 'do ') + return match(nonblankline, '\v\s*\zs', i) endif if line =~# '\v' && line !~# '\v^\s*#' diff --git a/test/do/double_do.in.hs b/test/do/double_do.in.hs new file mode 100644 index 0000000..5b255ac --- /dev/null +++ b/test/do/double_do.in.hs @@ -0,0 +1,3 @@ +do foo <- do bar <- baz +qux +quux diff --git a/test/do/double_do.out.hs b/test/do/double_do.out.hs new file mode 100644 index 0000000..fbbb55c --- /dev/null +++ b/test/do/double_do.out.hs @@ -0,0 +1,3 @@ +do foo <- do bar <- baz + qux + quux From 99171c8c3638f8119d178ee6cbaa4d4634d7c9d8 Mon Sep 17 00:00:00 2001 From: Mateo Gjika <104777599+mateoxh@users.noreply.github.com> Date: Mon, 3 Mar 2025 08:24:50 +0100 Subject: [PATCH 2/2] Ignore 'do' matches inside words --- indent/haskell.vim | 5 ++--- test/do/double_do.in.hs | 2 +- test/do/double_do.out.hs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/indent/haskell.vim b/indent/haskell.vim index 82915ea..eaff0c9 100644 --- a/indent/haskell.vim +++ b/indent/haskell.vim @@ -2,7 +2,7 @@ " Filename: indent/haskell.vim " Author: itchyny " License: MIT License -" Last Change: 2025/03/01 19:41:22. +" Last Change: 2025/03/03 09:45:31. " ============================================================================= if exists('b:did_indent') @@ -128,8 +128,7 @@ function! GetHaskellIndent() abort endif if nonblankline =~# '\v\s*[[:alnum:](]' - let i = strridx(nonblankline, 'do ') - return match(nonblankline, '\v\s*\zs', i) + return match(nonblankline, '\v.*\s*\zs') endif if line =~# '\v' && line !~# '\v^\s*#' diff --git a/test/do/double_do.in.hs b/test/do/double_do.in.hs index 5b255ac..1b9f783 100644 --- a/test/do/double_do.in.hs +++ b/test/do/double_do.in.hs @@ -1,3 +1,3 @@ -do foo <- do bar <- baz +do foo <- do undo <- baz qux quux diff --git a/test/do/double_do.out.hs b/test/do/double_do.out.hs index fbbb55c..b400314 100644 --- a/test/do/double_do.out.hs +++ b/test/do/double_do.out.hs @@ -1,3 +1,3 @@ -do foo <- do bar <- baz +do foo <- do undo <- baz qux quux