Skip to content

Conversation

erw7
Copy link
Contributor

@erw7 erw7 commented Mar 28, 2017

Implementation based on the work of equalsraf. Changes from the equalsraf work are as follows.

  • Changed uv_run to be called in pty_process_spawn because uv_connect_cb was not called before calling uv_read_start that caused assert.
  • Changed to poll using timer until uv_is_readable returns false because it does not stop process output polling until winpty-agent is finished.
  • Implemented emulate quotiong of libuv's arguments to build cmdline.
  • Changed by changing return value of pty_process_spawn.
  • Changed to set proc->pid.
  • Changed enable some test on windows.
  • Changed to use utf16_to_utf8 function implemented in mbyte.c.

We do not think that the place to quote the command line is optimal, so we need to consider it.

If the last sleep of tty-test.c is enabled, the following error occurs in the functionaltest.

-- Output to stderr:
Uncaught Error: attempt to call a number value
stack traceback:
        [C]: at 0x67191e2e

In the case of Windows, I disabled it, is it really necessary to sleep for 100 seconds even in other environments?

At the moment there are the following problems.

  • Nvim will crash in the next step.
    • nvim-qt.exe -- -u NONE
    • :terminal
    • :q
    There is no problem in the case of the following step.
    • nvim.exe -u NONE
    • nvim-qt.exe --server \\.\pipe\nvim-xxxx-0
    • :terminal
    • :q
    In this case the errorlevel is also 0.
  • In the following procedure E301: Oops, lost the swap file !!! error will occur.
    • nvim-qt.exe -- -u NONE
    • :e test
    • :call termopen("dir")

@equalsraf
Copy link
Contributor

@erw7 you can remove 2c84479 and 74b6348 they are already in the master branch.

@justinmk
Copy link
Member

Can you rebase this on master?

@equalsraf
Copy link
Contributor

Can you rebase this on master?

Some conflicts but the rebase works away that merge commit, see f877eb6

@erw7
Copy link
Contributor Author

erw7 commented Mar 28, 2017

How can I remove it. I'm sorry I was not used to git etc.

@brcolow
Copy link
Contributor

brcolow commented Mar 29, 2017

To remove the commits do:

git rebase -i HEAD~7 which will open up the editor you have configured with git.

If you don't have an editor configured yet, check out this stackoverflow

Now change the word pick before the 2c84479 and 74b6348 commits to drop, write the file and quit. Then do git push --force. At least, I think that's what you should do - not a git aficionado by any means and I frequently mess up.

@erw7
Copy link
Contributor Author

erw7 commented Mar 29, 2017

Thank you brcolow.
I tried it. 08661d3 to 439c203 are entering, but is this OK? Should I git rebase -i HEAD~6 and 08661d3 to 439c203 also need to drop?

@justinmk
Copy link
Member

git rebase -i upstream/master

Or origin/master

@erw7
Copy link
Contributor Author

erw7 commented Mar 29, 2017

I tried it, but this time 8f0aa5d has disappeared. I thought about going back with git reflog, but once I deleted all the local files, it does not remain. May I do as follows

git checkout -b patch-windows-terminal2  equalsraf/patch-windows-terminal
git pull -f origin patch-windows-terminal

@justinmk
Copy link
Member

With your current branch, just do git cherry-pick 8f0aa5d and it will bring that commit over.

@erw7
Copy link
Contributor Author

erw7 commented Mar 29, 2017

I tried it, but it becomes as follows.

>git cherry-pick 8f0aa5df
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

    git commit --allow-empty

Otherwise, please use 'git reset'
On branch patch-windows-terminal
Your branch is up-to-date with 'origin/patch-windows-terminal'.
You are currently cherry-picking commit 8f0aa5df.

nothing to commit, working tree clean
>git status
On branch patch-windows-terminal
Your branch is up-to-date with 'origin/patch-windows-terminal'.
You are currently cherry-picking commit 8f0aa5df.
  (all conflicts fixed: run "git cherry-pick --continue")
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

nothing to commit, working tree clean

I created another branch and tried git commit --allow-empty, 8f0aa5d came back, but it was empty.

I am sorry for taking care of it.

@erw7
Copy link
Contributor Author

erw7 commented Mar 29, 2017

After canceling the same change at 57b1dcd git cherry-pick 8f0aa5d, 8f0aa5d returned.
thanks a lot.

@justinmk
Copy link
Member

justinmk commented Mar 30, 2017

This works. Running vim in bash --login -i from git-for-windows 1.8.3 has messed up colors, but this is a good start!

@erw7 erw7 changed the title [WIP/RFC] Windows :terminal support [RFC] Windows :terminal support Mar 30, 2017
@erw7
Copy link
Contributor Author

erw7 commented Mar 30, 2017

What if you start vim as follows?

bash --login -i
export VIM=/usr/share/vim
export VIMRUNTIME=/usr/share/vim/vim80
vim

I finished this work for now.

@justinmk
Copy link
Member

The vim colors issue was bogus, same issue happens in normal cmd.exe (I didn't think to check there because I normally run a different version of vim there, not the old git-for-windows vim).

Thanks for working on this!

@marvim marvim added the RFC label Mar 30, 2017
@erw7 erw7 changed the title [RFC] Windows :terminal support [WIP/RFC] Windows :terminal support Mar 31, 2017
@erw7
Copy link
Contributor Author

erw7 commented Mar 31, 2017

There are many points that do not follow the coding guide. I'll fix them.

Please remove RFC label temporarily.

@ZyX-I
Copy link
Contributor

ZyX-I commented Mar 31, 2017

@erw7 Labels are managed by bot, based on the PR title.

@justinmk justinmk changed the title [WIP/RFC] Windows :terminal support [WIP] Windows :terminal support Mar 31, 2017
@marvim marvim added WIP and removed RFC labels Mar 31, 2017
@erw7 erw7 changed the title [WIP] Windows :terminal support [RFC] Windows :terminal support Apr 3, 2017
@marvim marvim added RFC and removed WIP labels Apr 3, 2017
@@ -102,6 +107,7 @@ int pty_process_spawn(PtyProcess *ptyproc)
NULL, // Optional environment variables
&err);
if (spawncfg == NULL) {
write_winpty_elog("Faied winpty_spawn_config_new.", &status, &err);
Copy link
Member

Choose a reason for hiding this comment

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

typo

FUNC_ATTR_NONNULL_ALL
{
PtyProcess *ptyproc =
(PtyProcess *)((uv_handle_t *)wait_eof_timer->data);
Copy link
Member

Choose a reason for hiding this comment

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

we don't cast void * pointers, instead just:

PtyProcess *ptyproc = wait_eof_timer->data;

DWORD dwProcessId;
GetWindowThreadProcessId(consoleWnd, &dwProcessId);
return GetCurrentProcessId() == dwProcessId;
// XXX: We need to make proper detect owns tty
Copy link
Member

Choose a reason for hiding this comment

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

is this planned for this PR, or later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not plan on this PR.
I do not understand what to check here on Windows.


for (int i = 0; i < cnt; i++) {
if (buf->base[i] == 3) {
(*interrupted)++;
} else if (buf->base[i] == 17) {
prsz = true;
Copy link
Member

Choose a reason for hiding this comment

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

could you add a comment mentioning where 17 comes from? Or make it a #define.

@@ -118,6 +118,10 @@ endforeach()

list(REMOVE_ITEM NVIM_SOURCES ${to_remove})

if (NOT WIN32)
list(REMOVE_ITEM NVIM_HEADERS "${PROJECT_SOURCE_DIR}/src/nvim/os/pty_process_win.h")
endif()
Copy link
Member

Choose a reason for hiding this comment

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

@erw7 Do you happen to remember why this was needed? I removed it in b885b93 and it seems to build OK on linux, bsd, and macOS.

Copy link
Member

Choose a reason for hiding this comment

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

I see now it fails the "single includes" test. Addressed that in 90de721

Copy link
Contributor Author

@erw7 erw7 Aug 7, 2017

Choose a reason for hiding this comment

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

Failed "single include" test as you say.
Will you work #7007 after this? Then I close this pull request.

Copy link
Member

Choose a reason for hiding this comment

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

@erw7 Yes, #7007 is almost ready, it's an effort to merge your work here.

rprichard and others added 23 commits August 8, 2017 02:27
Handling of process exit is still broken.  It detects the moment when the
child process exits, then quickly stops polling for process output.  It
should continue polling for output until the agent has scraped all of the
process' output.  This problem is easy to noticed by running a command like
"dir && exit", but even typing "exit<ENTER>" can manifest the problem --
the "t" might not appear.

winpty's Cygwin adapter handles shutdown by waiting for the agent to close
the CONOUT pipe, which it does after it has scraped the child's last
output.  AFAIK, neovim doesn't do anything interesting when winpty closes
the CONOUT pipe.
Changing to make sure that proc->in, proc-> is not NULL, because nvim
crashed when starting a job with pty.

Changing to make sure that proc->out is not NULL, because nvim crashed
when stopping a job opened with pty.
Remove pty_process_win.h from NVIM_HEADERS on *nix.
tty-test.exe causes abnormal termination with low repeatability, try
changing it so as not to use SIGWINCH.
@justinmk
Copy link
Member

justinmk commented Aug 7, 2017

#7007 will merge this. Many thanks to @erw7 !

@justinmk justinmk closed this Aug 7, 2017
@justinmk justinmk removed the RFC label Aug 7, 2017
justinmk added a commit that referenced this pull request Aug 16, 2017
@erw7 erw7 deleted the patch-windows-terminal branch September 11, 2019 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants