Closed dhm116 closed 8 years ago
You mean in the copied code? Good idea. Only problem is that the comment syntax is different based on the current language which makes this a bit more complicated.
I haven't had time to dig into whether this would work or not, but would something like https://atom.io/docs/api/v1.4.1/Selection#instance-toggleLineComments work?
Perhaps. Thanks for the suggestion.
I came across this thread because I was thinking about implementing something like this - if I get chance I will give it a go. Thanks @dhm116 for the API reference.
It should be noted that you are technically required to provide a link to StackOverflow code, unless using it under fair use.
See http://blog.stackoverflow.com/2009/06/attribution-required/
Yep for the time being. This will change in a few weeks though: http://meta.stackexchange.com/questions/272956/a-new-code-license-the-mit-this-time-with-attribution-required
@Chris911 Well, they changed their mind I'm pretty sure (given the vote). We have no idea what the license is going to be.
@ChristopherKing42 this was part of the reason for my previous patch that was @Chris911 applied to the release - since the questions and answers listed didn't either show the original author or wasn't linked back to their profile (which is point 3 and 4 of the above link).
@Chris911 already had a link back to the question (point 2). And point 1 is obvious from the package and the tab's name.
I appreciate that those changes I did in the last update are for the interface, and not for the imported code examples, but since the package is essentially publishing the data it should also conform there too.
Most good programmers will attribute the authors anyway, and the package does provide them with enough information for them to do so. That said, I'm sure that if @Chris911 doesn't do it for the code imports, then I probably will when I get the time to. Since it would be nice for it to do it automatically.
To make this issue report more constructive, I think we should discuss the style we would like it to appear in the code.
@dhm116 thanks for the link, I ended up passing in a {select: true}
as an option for insertText(text, [options]), and then using toggleLineCommentsInSelection() followed by toggleLineCommentsInSelection().
EDIT:
I also coupled this by using the transact
method which allows you to wrap several amendments as part of one undo transaction - so that you don't have to undo multiple edits to the document.
E.g.
editor = atom.workspace.getActivePaneItem();
editor.transact =>
editor.insertText('hello', {select: true});
editor.toggleLineCommentsInSelection();
editor.insertNewlineBelow();
editor.insertText('world', {select: true});
editor.toggleLineCommentsInSelection();
editor.insertNewlineBelow();
This will insert "hello" and comment it out, add a new line, insert "world", comment that out, and insert a new line, then you can undo the two commented out lines with one simple undo.
I believe this can now be closed, right?
I think so. Fixed via https://github.com/Chris911/Ask-Stack-Atom/issues/35
I'm also updating the animated gif in the README to reflect the new changes.
Nice! Hopefully it might attract more people seeing the new additions. Just a small one, but it might be worth adding a link to the package in the repo description. https://atom.io/packages/ask-stack
There's already a link in the README under "package homepage" but I can add it in description on top as well.
True, I only added it to the description in my fork because I'm lazy. However, it is also the first place I look when seeing someone's repo, so I can only imagine that's where most people would look first too.
@Chris911 just noticed that the gif/image hadn't been updated. Thought I would mention it incase you created it but forgot to upload it.
Yeah I created it but the image size was too big (15+ mb). I might give it another go this week. Ideally I'd like to host the image not in the repo as it will increase the size for nothing.
This might be an alternative solution for doing just that: https://git-lfs.github.com/ or alternatively, create a new repo for resource files such as images and link to it that way? There's also things like imgur, etc...
Based on the animated gif showing the plugin usage, it did not appear that a link to the original SO post was included when importing code. That should probably be added, right?