[vim/vim] csh: Support negated if in matchit (PR #19172)

3 views
Skip to first unread message

Simão Afonso @ Powertools Tech

unread,
10:20 AM (12 hours ago) 10:20 AM
to vim/vim, Subscribed

Currently, the matchit configuration chokes on valid syntax like:

if !(true) then
   true
endif

Make sure the negation syntax is supported.

Ping @dkearns


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/19172

Commit Summary

  • 0a61fa3 csh: Support negated if in matchit

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19172@github.com>

dkearns

unread,
12:00 PM (10 hours ago) 12:00 PM
to vim/vim, Subscribed
dkearns left a comment (vim/vim#19172)

I was surprised that this works. The documentation seems very clear that the parens are required as expression delimiters, like C. However, any expression is accepted there and the parens are not required at all.

Looking at the source I couldn't tell for sure whether it was an oversight or intentional but there is a solitary example in the test harness not using parens so I'm favouring the latter. It's also been that way forever.

Parsing the expression to disambiguate single and multiline if commands sounds annoying at best.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19172/c3745413772@github.com>

dkearns

unread,
12:01 PM (10 hours ago) 12:01 PM
to vim/vim, Subscribed

@dkearns commented on this pull request.


In runtime/ftplugin/csh.vim:

> +	\ s:line_start .. 'if\s*!\?\s*(.*)\s*then\>:' ..
 	\   s:line_start .. 'else\s\+if\s*(.*)\s*then\>:' .. s:line_start .. 'else\>:' ..

Something like this (untested) is better but we need to look behind to check for operators and param $ etc. to avoid matching then at the end of an expression.

⬇️ Suggested change
-	\ s:line_start .. 'if\s*!\?\s*(.*)\s*then\>:' ..
-	\   s:line_start .. 'else\s\+if\s*(.*)\s*then\>:' .. s:line_start .. 'else\>:' ..
+	\ s:line_start .. 'if\>.*\<then\>\s*\%(;\|$\):' ..
+        \   s:line_start .. 'else\s\+if\>.*\<then\>\s*\%(;\|$\):' .. s:line_start .. 'else\>:' ..


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19172/review/3656879452@github.com>

Simão Afonso @ Powertools Tech

unread,
1:03 PM (9 hours ago) 1:03 PM
to vim/vim, Subscribed

@simaoafonso-pwt commented on this pull request.


In runtime/ftplugin/csh.vim:

> +	\ s:line_start .. 'if\s*!\?\s*(.*)\s*then\>:' ..
 	\   s:line_start .. 'else\s\+if\s*(.*)\s*then\>:' .. s:line_start .. 'else\>:' ..

That might work, but it can be too big of a change to test. The vast majority of usage includes the parens, I guess.

I tested that change, but it doesn't work, I guess it was actually pseudo-code.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/19172/review/3657136409@github.com>

Reply all
Reply to author
Forward
0 new messages