Skip to content

feat(terminal): parse current buffer contents in nvim_open_term() #33720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gpanders
Copy link
Member

When nvim_open_term() is called with a non-empty buffer, the buffer contents are piped into the PTY.

@gpanders gpanders requested a review from Copilot April 29, 2025 14:32
@github-actions github-actions bot added the terminal built-in :terminal or :shell label Apr 29, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces functionality to parse and send non-empty buffer contents through the PTY when nvim_open_term() is called. Key changes include:

  • Modifying documentation to indicate that non-empty buffers will have their contents written to the PTY.
  • Adding logic to read and concatenate buffer lines, appending newline characters as needed.
  • Sending the concatenated contents to the channel after opening the terminal.
Files not reviewed (3)
  • runtime/doc/api.txt: Language not supported
  • runtime/lua/vim/_meta/api.lua: Language not supported
  • test/functional/api/vim_spec.lua: Language not supported

@gpanders gpanders requested a review from justinmk April 29, 2025 14:34
When nvim_open_term() is called with a non-empty buffer, the buffer
contents are piped into the PTY.
@gpanders gpanders force-pushed the push-uqqpvpyuslpo branch from ebdd132 to 96351ae Compare April 29, 2025 18:31
for (linenr_T lnum = 1; lnum <= buf->b_ml.ml_line_count; lnum++) {
char *bufstr = ml_get_buf(buf, lnum);
colnr_T bufstrlen = ml_get_buf_len(buf, lnum);
kv_concat_len(contents, bufstr, (size_t)bufstrlen);
Copy link
Member

@zeertzjq zeertzjq Apr 29, 2025

Choose a reason for hiding this comment

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

Translate NL to Nul when concatenating? And this shares some common code with read_input() in src/nvim/os/shell.c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
terminal built-in :terminal or :shell
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants