Giter Club home page Giter Club logo

Comments (11)

rgbkrk avatar rgbkrk commented on August 20, 2024

That bit of strangeness comes from using python -e.

If we wanted to get around that, we'd have to make a tempfile.

from atom-script.

hayd avatar hayd commented on August 20, 2024

Ach, weird new lines aren't interpreter as such:

 $ python -c "\n\nfoo" 
  File "<string>", line 1
    \n\nfoo
          ^
SyntaxError: unexpected character after line continuation character

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

Color me corrected, I understand now.

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

Looking back at the gif, it's because I selected the line above it. Check this out:

python line

I think the demo gif is just a bit haphazard for when I'm selecting (I get nervous recording for the world I think).

from atom-script.

hayd avatar hayd commented on August 20, 2024

Yeah, line 2 makes sense, I was suggesting it could show line 22.

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

ohhh, so sorry. Yeah, we should prepend newlines. Kind of hacky but it would be nice.

I think the reason python -c "\n\nfoo" didn't handle well is that it interpreted as a literal backslash n.

from atom-script.

erran avatar erran commented on August 20, 2024

@rgbkrk @hayd My changes from #107/#108/#109 should help:

"Selection Based":
  command: "python"
  args: (filename, selection) ->
    buffer_row_range = selection.getBufferRowRange()
    line_number = buffer_row_range.reduce (a, b) -> Math.min(a, b)
    line_number += 1
    n = 1
    # ... calculate the number of newlines to add ...
    [Array(n).join("\n"), filename]

from atom-script.

erran avatar erran commented on August 20, 2024

Just realized this happens for at least Ruby, Coffeescript, and Perl too... 😆 I guess the solution is to prepend the whitespace "\n" to all grammars? @rgbkrk What's your opinion?

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

As long as the whitespace doesn't affect the interpretation of the code.

from atom-script.

rgbkrk avatar rgbkrk commented on August 20, 2024

Also, yuck. The only other solution would be if you could specify to an interpreter what line number to treat it as coming from. AFAIK, that's not a feature anywhere. Sadly, I think prepending newlines is what we need to do.

from atom-script.

erran avatar erran commented on August 20, 2024

Yeah. Should we make it an optional/boolean param on the getCode method (prepend set to true/false) and manually enable it per languages vs. polluting all of them with whitespace (some interpreters could be picky about it)?

from atom-script.

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.