GithubHelp home page GithubHelp logo

Comments (4)

antonscharton avatar antonscharton commented on June 2, 2024 2

Had the same issue and this bugged me a lot. I came up with a small workaround
to restore original behavior of the hydrogen run command.

Add to the init.js script

atom.commands.add('atom-text-editor', 'custom:hydrogen-run', function () {
  const editor = this.getModel();
  atom.commands.dispatch(atom.views.getView(editor), 'editor:select-line');
  atom.commands.dispatch(atom.views.getView(editor), 'hydrogen:run');
  atom.commands.dispatch(atom.views.getView(editor), 'editor:move-to-end-of-line');
});

and map a key-binding to this function in the keymap, e.g.:

'atom-text-editor':
  'shift-enter': 'custom:hydrogen-run'

EDIT:

If you want it to work with (python) indent-blocks, e.g. function definitions in python, you could do the following.
This would allow you to put the cursor on the first line and the code will figure out the corresponding indent block.

atom.commands.add('atom-text-editor', 'custom:hydrogen-run', function () {
  const editor = this.getModel();

  atom.commands.dispatch(atom.views.getView(editor), 'editor:select-line');
  const row = editor.getLastSelection().getBufferRange().start.row;
  var k = 1;
  
  while (/^\s+$/.test(editor.getTextInBufferRange([[row+k, 0], [row+k, 1]]))) {
    atom.commands.dispatch(atom.views.getView(editor), 'core:select-down');
    k = k + 1;
  }
  if (k != 1){
    atom.commands.dispatch(atom.views.getView(editor), 'editor:select-to-end-of-line');
  }

  atom.commands.dispatch(atom.views.getView(editor), 'hydrogen:run');
  atom.commands.dispatch(atom.views.getView(editor), 'editor:move-to-end-of-line');
});

from hydrogen.

contang0 avatar contang0 commented on June 2, 2024

Same here. I'm always using the "Run cell and move down" command, but it only works if I highlight the code to be run. If I don't, I get the error @ttxtea mentions. Meanwhile, the "Run cell" command runs everything in the file, whereas it should really only run current line / block or what is highlighted.

from hydrogen.

contang0 avatar contang0 commented on June 2, 2024

@antonscharton this worked great! The second snippet is exactly what I needed.

from hydrogen.

AJSchiller avatar AJSchiller commented on June 2, 2024

Thanks @antonscharton ! This restores expected behaviour for me, but I still get the error pop-up everytime. Does it do that for anyone else?

from hydrogen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.