atom-archive / terminal

Atom Terminal package - *not currently maintained*
MIT License
232 stars 35 forks source link

Open in current project path #23

Closed DAddYE closed 6 years ago

DAddYE commented 10 years ago

Would be nice if when we open the terminal could chdir in current project.

ciarand commented 10 years ago

I don't have the beta yet, but it looks like it is supposed to be: https://github.com/atom/terminal/blob/master/lib/terminal.coffee#L16

One could probably troubleshoot this just by playing around with the API.

It also looks like the order of URI params is different between the above file and this one: https://github.com/atom/terminal/blob/master/lib/terminal-session.coffee#L47

I don't know if that could be causing this.

adrianlee44 commented 10 years ago

After digging a bit more, it seems like the terminal-process is not getting the cwd.

https://github.com/atom/terminal/blob/master/lib/terminal-process.coffee#L3

ptyCwd is null even though terminal-session is passing the correct value.

lackac commented 10 years ago

I successfully tracked down the issue to a bug in the Task class of atom's core. I don't have the CoffeeScript source, so I'm going to show the fix in the compiled js code:

    Task.prototype.start = function() {
      var args, callback, _i;
      args = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), callback = arguments[_i++];
      if (this.childProcess == null) {
        throw new Error("Cannot start terminated process");
      }
      this.handleEvents();
      if (_.isFunction(callback)) {
        this.callback = callback;
      } else {
        // WAS: args = arguments;
        args = Array.prototype.slice.call(arguments);
      }
      return this.send({
        event: 'start',
        args: args
      });
    };

The problem is caused by the args = arguments assignment. arguments is not an array, and somehow when it is sent to the child process, its length property gets lost and the child process cannot use it as an array like object anymore. The part of the child process that uses this args object is in task-bootstrap.js.

With the change above, the child process properly receives the array and is able to apply it to the handler function which in the case of the terminal package is the function exported by terminal-process.coffee.

Try this out by adding this change to /Applications/Atom.app/Contents/Resources/app/src/task.js. It is on line 85 in v0.73.0. Now, someone with access to the atom's core, please apply this change and release a new version. :)

nathansobo commented 10 years ago

@lackac Great find under very adverse conditions. This is why I can't wait to get people access to core. I went with a slightly different fix to avoid the Array::slice.apply dance (I just push callback to the end of args in the else case). Should be out with the next version soon. Thanks!

lee-dohm commented 6 years ago

All repositories in the atom-archive organization are unmaintained and deprecated. Because of this, we are archiving this repository and closing all issues and pull requests. Thanks very much for your support and contributions!