hharnisc / hypercwd

Opens new tabs with the same directory as the current tab in Hyper
MIT License
384 stars 39 forks source link

Open new tab take lots of time on Hyper 2.1.0-canary.3 #58

Open ohardy opened 5 years ago

ohardy commented 5 years ago

Hi,

Its take lots of time to open a new tab or split with the last canary version of Hyper. No specific console log.

Any ideas ?

marwankhalili commented 5 years ago

This might be related to https://github.com/zeit/hyper/issues/2838

ohardy commented 5 years ago

Note sure. Everything was ok on canary 2 and if I disable hypercwd, I have no issue anymore

hpohlmeyer commented 5 years ago

Still the same with 2.1.0 stable for me.

LeanderFS commented 5 years ago

The problem is located in the setCwd function which contains an exec call to get the current working directory. In the current code it is assumed that exec returns a single string value but it actually returns 3 (error, stdout and stderr). The trim() called on the returned object therefore has no effect and fails to do so.

In the snippet below, promiseExec returns an object, so newCwd.trim() should actually be newCwd.stdout.trim().

const newCwd = await promiseExec(
    `lsof -p ${tab.pid} | grep cwd | tr -s ' ' | cut -d ' ' -f9-`);
  const cwd = newCwd.trim();

It doesn't seem like this repository is being actively maintained, so I decided to write a quick replacement plugin. It's located here hyper-samewd. Install with hyper i hyper-samewd

ruucm commented 5 years ago

@LeanderFS Thanks! I also changed the plugin to hypersamewd !

MikuroXina commented 5 years ago

The same thing happened. I'd tried to use hyper-samewd, but it had not worked. However, by rewriting the code of setCwd.js as following, somehow it worked well.

const newCwd = await promiseExec( // Specify LANG and not resolving domains
  `LANG=en_US.utf-8 lsof -n -p ${
    tab.pid
  } | grep cwd | tr -s ' ' | cut -d ' ' -f9-`
);

But it has not tested in various environments. My environment is macOS 10.14.2, Hyper 2.1.1, Japanese. Could you please test with other systems or languages? (Maybe my english is not good because I'm Japanese, sorry.)