Skip to content

:append in a block that is not executed reads its text as commands - #21331

Closed
h-east wants to merge 1 commit into
vim:masterfrom
h-east:skip-text-input-commands
Closed

h-east wants to merge 1 commit into
vim:masterfrom
h-east:skip-text-input-commands

Conversation

@h-east

@h-east h-east commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor
Problem:  Inside a block that is not executed, "if 0" for one, the text
          of ":append", ":insert" and ":change" is read as commands: the
          commands are not executed while skipping, so nothing reads the
          lines up to the ".".  A text line like "endif" then ends the
          block.  A ":source ++dryrun" has the same problem at the script
          level.  The three commands are also missing from the list at
          ":help :bar".
Solution: Execute the three commands while skipping, like ":function",
          and only read the lines up to the "." then.  Add them to the
          ":help :bar" list.

related: #21257

@h-east

h-east commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor Author

@dkearns You said in #21257 (comment) that you had a patch for this, so I waited a few
days before opening this one. If you would rather submit your own, let me
know and I will close this PR.

(I feel like I've written this exact same thing to you before...)

@dkearns

dkearns commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

@dkearns You said in #21257 (comment) that you had a patch for this, so I waited a few days before opening this one. If you would rather submit your own, let me know and I will close this PR.

Are you actually complaining about delivery times again? I don't get paid enough just to deal with you, let alone meet your deadlines.

I'm sorry you're losing sleep over a patch for a twenty-five-year-old bug, affecting no one, that you were neither diligent nor competent enough to notice yourself when excreting your latest feature addition. What's the hurry, is your subscription ending soon?

(I feel like I've written this exact same thing to you before...)

I must be getting old because I had to rack my brain to guess at what you were referring to here. Then it came to me, you might be pointing to that time you, bizarrely, created a PR to fix the :apple bug, that I'd assigned to myself, fixed, and informed you of its status. Is that really what you're referencing? The time you broke parsing of text-input commands in function bodies and shipped it with the 9.2 release for good measure? The time you, thankfully, didn't bother to 'fix' the same problem a few lines below? Am I getting warm here?

As for this PR, sure merge it. It's relatively harmless, half-implemented, unidiomatic, and undocumented slop but it'll get fixed properly sooner or later. How's life on the push-button happy path? Are edge cases slowing your roll? I find it appalling that you are obviously one-shotting PRs for a three-decade-old project with the legacy of Vim.

Sadly, I'm perfectly comfortable using this tone since you spend so much of your time running around this project snarling at other developers about how they're failing to respect your authority, like that little chap from South Park.

@h-east

h-east commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

A bug that nobody reports does not get fixed. An issue or a review
comment at the time is what gets a bug fixed.

A bug in a feature few people use is hard to notice. That is what
reports are for.

Bringing an unreported bug out later as material for a personal attack
is not what a maintainer does.

@chrisbra

Copy link
Copy Markdown
Member

closing here

@chrisbra chrisbra closed this Sep 21, 2026
@h-east
h-east deleted the skip-text-input-commands branch September 21, 2026 20:25
@h-east

h-east commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

For the record, this is a different defect from the one #21346 fixes.
That one is about the parsing of a function body, with arguments and a
comment at the end of the line. This one is about a block that is not
executed: ":append" is not executed either, so nothing reads the lines
that belong to it and they are parsed as commands. On 9.2.1122:

    if 0
      append
    endif
    .
    endif
    let g:skipped = "append"

The "endif" on line 3 is the text of the ":append", but it closes the
block, and the one on line 5 then gives "E580: :endif without :if".
Reading a function body does take those lines as text, so the two paths
do not agree.

@h-east
h-east restored the skip-text-input-commands branch September 26, 2026 14:23
@h-east

h-east commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

@chrisbra
Could you reopen this? As I wrote above, #21346 fixes a different
defect, and this one is still there on 9.2.1132. I have restored the
branch; once it is open again I will rebase it onto master, since
9.2.1132 touches the same list in do_one_cmd().

@chrisbra chrisbra reopened this Sep 26, 2026
Problem:  Inside a block that is not executed, "if 0" for one, the text
          of ":append", ":insert" and ":change" is read as commands: the
          commands are not executed while skipping, so nothing reads the
          lines up to the ".".  A text line like "endif" then ends the
          block.  A ":source ++dryrun" has the same problem at the script
          level.  The three commands are also missing from the list at
          ":help :bar".
Solution: Execute the three commands while skipping, like ":function",
          and only read the lines up to the "." then.  Add them to the
          ":help :bar" list.

Assisted-by: Claude
Signed-off-by: Hirohito Higashi <[email protected]>
@h-east
h-east force-pushed the skip-text-input-commands branch from 6573587 to 0222224 Compare September 26, 2026 17:05
@h-east

h-east commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for reopening. Done.

@chrisbra

Copy link
Copy Markdown
Member

alright thanks

@chrisbra chrisbra closed this in ae8837c Sep 30, 2026
@h-east
h-east deleted the skip-text-input-commands branch September 30, 2026 20:45
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Oct 1, 2026
… text as commands

Problem:  In a block that is not executed, the text lines of :append,
          :insert and :change are parsed as commands, so e.g. a text
          line "endif" ends the block
Solution: Read and discard the text up to "." while skipping.  Add the
          commands to the ":help :bar" list.

closes: vim/vim#21331

vim/vim@ae8837c

Co-authored-by: Hirohito Higashi <[email protected]>
zeertzjq added a commit to zeertzjq/neovim that referenced this pull request Oct 1, 2026
… text as commands

Problem:  In a block that is not executed, the text lines of :append,
          :insert and :change are parsed as commands, so e.g. a text
          line "endif" ends the block
Solution: Read and discard the text up to "." while skipping.  Add the
          commands to the ":help :bar" list.

closes: vim/vim#21331

vim/vim@ae8837c

Co-authored-by: Hirohito Higashi <[email protected]>
Comment on lines +211 to +215
if false
append
enddef
.
endif

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong. In Vim9 script, :append leads to an error and doesn't consume any following lines when it's not skipped, so it shouldn't consume following lines when it's skipped either.

#21415

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. thanks for following up on this!

zeertzjq added a commit to neovim/neovim that referenced this pull request Oct 1, 2026
… text as commands (#42196)

Problem:  In a block that is not executed, the text lines of :append,
          :insert and :change are parsed as commands, so e.g. a text
          line "endif" ends the block
Solution: Read and discard the text up to "." while skipping.  Add the
          commands to the ":help :bar" list.

closes: vim/vim#21331

vim/vim@ae8837c

Co-authored-by: Hirohito Higashi <[email protected]>
@dkearns

dkearns commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

I wish I were incredulous that you'd pushed for the resurrection and merging of this PR, unmodified.

Along with completely ignoring Vim9 handling, which has now been implemented at least twice, this PR also completely ignores Vim's unique autoindented end '.' marker behaviour in script files.

I'm planning on making a case for removing support for indented '.' from scripts. It seems clear to me that it was only implemented as an interactive convenience in Vi but it's harder to be certain of the intent with Vim. Without giving it much thought over the years, I'd always assumed it was supposed to function like "trim". I'm waiting on someone to get back to me regarding a related reading of the POSIX spec and since the 'feature' has been around for a long time in Vim I wanted to do a decent survey of its usage. I had planned to remove it before bothering with skipping as it's impossible to properly support.

This implementation also indulges the AI's fetish for pointless function extraction and early returns.

If skipping was considered fixed properly we should also have updated the help to reflect that.

@chrisbra cannot be expected review this flood of PRs in extreme detail and is relying on contributors to at least make a fair effort to get things right. Ten minutes of testing this by hand would turn up most of the problems. #21349 has more of the same and worse, from a quick skimming.

clason pushed a commit to clason/neovim that referenced this pull request Oct 6, 2026
… text as commands (neovim#42196)

Problem:  In a block that is not executed, the text lines of :append,
          :insert and :change are parsed as commands, so e.g. a text
          line "endif" ends the block
Solution: Read and discard the text up to "." while skipping.  Add the
          commands to the ":help :bar" list.

closes: vim/vim#21331

vim/vim@ae8837c

Co-authored-by: Hirohito Higashi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants