Skip to content
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

Tab inserts tab #55

Merged
merged 12 commits into from
Sep 9, 2016
Merged

Tab inserts tab #55

merged 12 commits into from
Sep 9, 2016

Conversation

bernardlee
Copy link
Collaborator

I've moved the tab inserts tab option to the package configuration view. Having the option checked will make the tab key insert tab characters in the textarea elements in the headers and payload sections.

Add a constant, TAB_KEY, equal to 9.
Add a key "tab_inserts_tab", with value ".rest-client-tab-inserts-tab",
to the rest_form object.
Add a div element between Saved requests and Headers with a checkbox to
toggle the tab inserts tab option.
If the "tab inserts tab" option is checked when pressing the tab key in
a textarea element, then it will insert a tab character.
Remove the key "tab_inserts_tab" from the rest_form object and remove
the div containing the checkbox for the option.
Add a checkbox to toggle an option to insert a tab character whenever
the tab key is pressed.
Remove all changes made.
Add a command to Atom in the scopes for .rest-client-headers and
.rest-client-payload called rest-client:insertTab to call insertTab().
Add an Atom configuration observer to add or remove a keymap for the tab
key when the tab inserts tab option is changed.  Add a method called
insertTab() that manipulates the textarea element to insert a tab
character.
Change "if start == end" to "if start is end" as suggested by Codacy.
@bernardlee
Copy link
Collaborator Author

Hello. I'm not too familiar with CoffeeScript but I did try to adhere to the style in the existing source code. Codacy is telling me that there's inconsistent indentation in what I wrote but it doesn't seem out of place. Can somebody please point me in the right direction to make the appropriate corrections? Thank you.

@ddavison
Copy link
Owner

ddavison commented Sep 9, 2016

as long as your editor (and you) abide by the .editorconfig file :)

Refactor "tab inserts tab"-related code to reduce redundancy and adhere
more to CoffeeScript's style.
end = event.target.selectionEnd
endText = if start is end then text.slice(start) else text.slice(end, text.length)

event.target.value = text.slice(0, start) + '\t' + endText
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i might be biased, but @javaguirre , do you think \t should be (two spaces instead of\t? this is difficult for me to answer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Dj. I can add an option to allow the user to choose or input their own character(s) to insert, if that's preferred.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a great idea @bernardlee ! great way to settle in the middle :)

I think two options:
Dropdown: Space/Tabs
Length: 2/4

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or if you want, leave the length a text field, and default to "2".

Rename tab_inserts_tab to tab_key_behavior and change its type to an
object to represent a group of settings.  Add an option to enable soft
tabs and another to determine the length.
Add all functionality that the new whitespace options represent: soft
tabs and their length.
@bernardlee
Copy link
Collaborator Author

bernardlee commented Sep 9, 2016

I added a couple of options to enable or disable soft tabs and to determine their length. There's probably a better way to implement this functionality than the way that I did it, but I'm still new to playing with the Atom API so let me know if there's a better way and I'll update it.

@ddavison ddavison merged commit 2f40638 into ddavison:master Sep 9, 2016
@ddavison
Copy link
Owner

ddavison commented Sep 9, 2016

you sir, deserve a cookie. 🍪

thanks so much

@ddavison
Copy link
Owner

ddavison commented Sep 9, 2016

available as v1.2.4

@bernardlee
Copy link
Collaborator Author

Thank you!

@bernardlee bernardlee deleted the tab-inserts-tab branch September 9, 2016 21:47
@jonatanklosko jonatanklosko mentioned this pull request Oct 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants