-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "Line Based" support #112
Conversation
@@ -6,4 +6,5 @@ | |||
'cmd-i': 'script:run' | |||
'ctrl-w': 'script:close-view' | |||
'ctrl-c': 'script:kill-process' | |||
'shift-cmd-j': 'script:run-at-line' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have used shift-cmd-l
, but this is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rgbkrk I was actually thinking the same. I have fat fingered cmd-j
a few times which causes Atom to join lines (remove the previous line's new line char).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rgbkrk Just realized that shift-cmd-L
is used by Core. I stripped this change.
I'm not a big fan of this argument explosion. A little bird tells me we should create a |
@rgbkrk Sounds good. I'll do that tonight. It's worth mentioning that when selecting the entire line the next line is the number that is used. From memory of my earlier implementation: checking for the current selection and grabbing |
Sorry I had not come back to this for a bit. I definitely appreciate the CodeContext abstraction and that this will work well across line, selection, and file based runs. 😄 |
@rgbkrk If we do we'd have to send |
I'm not sure I follow do you mean in specs or to check that it's set. If the latter, where would I check since it's set outside of any conditionals. |
I mean adding specs to this PR, so we can actually have unit tests for our own sanity. See merge-conflicts for some great examples. |
@rgbkrk you got it. I'll try to get to this tomorrow night or Wednesday some time. |
Still in the mood for some tests? 😉 |
I've been on vacation for the last three weeks. I'll try to get to it this week, assuming no urgent things popped up at work, though. |
Hey I understand that. Hope vacation was great! |
Started with something. See this commit 82eb5e4. |
Most definitely. I think you can clean out those junk tests that were basically boilerplate at this point. |
@rgbrkrk I ended up pushing what I had for the night. Turns out I can't find my Mac charger at home since my vacation, so I'll have to bring the spare from the office tomorrow. 😩 |
Ok, finally had a chance to look over this again with the new CodeContext object. I was really hoping that we would just use the CodeContext piece within all the grammars instead of casing off which argument is being run (as well as introducing that new parameter). |
@@ -130,6 +136,9 @@ module.exports = | |||
"File Based": | |||
command: "rspec" | |||
args: (filename) -> ['--tty', '--color', filename] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm expecting us to use the CodeContext objects here too, instead of the filename as the argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! 😄 Not sure what made me change this (or abstain from doing so).
Not surprisingly, since I just merged in Yet Another Language™ you'll need to fetch and rebase against upstream/master (or whatever remote name you have configured for github.com/rgbkrk/atom-script).
|
+ Add keymaps for "Line Based" runs + Add menus for "Line Based" runs + Update grammars.coffee for "Line Based" runs
@rgbkrk I had less merge conflicts than I'd have guessed. 😉 |
@rgbkrk Going to sort out the specs now. Let me know if you have any other things to change in mind. |
else | ||
arg = selection.getText() | ||
|
||
console.log "#{argType} executing" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this meant as a debug statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! 😲
+ Update related specs
I'm currently trying to see if there's a good way to abstract this a bit more. Having |
@rgbkrk setup lines 74 through 97 could probably be moved into a
|
Yeah, gimme a sec. I'll probably end up submitting a PR against your branch shortly. |
@rgbkrk Fine with me. 👍 |
* Move CodeContext creation into its own build step * Move language validation to its own function * Finish extracting lang, codeContext * Simplify line based path * Separate line and file/selection runs * Simplify code context selection
Move code context creation
Playing with a fix for #86 I ended up with this. EDIT: Just realized that my change currently subtracts an extra line if we're going by a partial selection vs. an entire line. Which should we choose as the default? It's a matter of the shortcuts or no. of clicks a user uses for their selection. |
My second shot on a fix for #86 |
Love your color scheme, love the new README GIF, glad you showed off the right-click to run at line. |
code = @codeContext.getCode() | ||
|
||
expect(typeof code).toEqual('string') | ||
expect(code).toMatch("print 'hello world!'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must say, thanks again for adding the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem!
Once you add the comment about why the whitespace was added for Python runs (or addressed for more langs), we |
I think I'll remove that commit for the sake of this PR since the proper fix would be multi-lingual. |
I was about to say the same thing. Let's hash that out in a new PR. |
@rgbkrk Removed the commit. I'll add a new PR soon. |
I'll make the release and update the relevant bits tomorrow morning. For now, I'm going to 😴. If you get the whitespace fix in the next day, we'll add that in as part of the release. |
ctrl
clicking the line number will provide a menu option to run at the current line.