Sitelet https://web.archive.org/web/20200902062003/https://github.com/cpeditor/cpeditor/issues/393
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

Optionally unindent when typing "}" at the beginning of a line #393

Open
sahil-ra opened this issue Jun 7, 2020 · 13 comments
Open

Optionally unindent when typing "}" at the beginning of a line #393

sahil-ra opened this issue Jun 7, 2020 · 13 comments

Comments

@sahil-ra
Copy link

@sahil-ra sahil-ra commented Jun 7, 2020 •

Is your feature request related to a problem? Please describe.
When I turn off auto-completion, the indentation of the closing bracket is not correct.
e.g :

int main() {
    cout << "Hi";
    }

There is a tab space there when closing the bracket.
Geany, does the indentation correct for reference.

Describe the solution you'd like
When closing the bracket, it should align with the opening bracket.
e.g:

int main() {
    cout << "Hi";
}

Describe alternatives you've considered

Additional context

@sahil-ra sahil-ra added the enhancement label Jun 7, 2020
@ouuan
Copy link
Member

@ouuan ouuan commented Jun 7, 2020 •

I think you are requesting the feature which removes an indent when typing "}"?

@sahil-ra
Copy link
Author

@sahil-ra sahil-ra commented Jun 7, 2020 •

void main() {
	for(int i ) {
		}
		}

This is what the indentation looks like now.

void main() {
	for(int i ) {
	}
}

This is what i would like it to be.

@ouuan
Copy link
Member

@ouuan ouuan commented Jun 7, 2020

You want the second indentation, and that can be achieved by the feature I described (remove an indent when typing "}"). If you think that's what you want, reply with a simple "yes", otherwise, describe what you want exactly.

@ouuan ouuan changed the title During auto completion off Indentation is not correct. Optionally unindent when typing "}" at the beginning of a line Jun 7, 2020
@sahil-ra
Copy link
Author

@sahil-ra sahil-ra commented Jun 8, 2020

Yes

@sonulohani
Copy link
Contributor

@sonulohani sonulohani commented Jun 8, 2020

Seems like need to make changes in https://github.com/Megaxela/QCodeEditor

@coder3101
Copy link
Member

@coder3101 coder3101 commented Jun 8, 2020

Seems like need to make changes in https://github.com/Megaxela/QCodeEditor

We use QCodeEditor as submodule. We have our own fork of the above repository. So you need to make change to https://github.com/cpeditor/QCodeEditor and propose a PR to master branch. We will take care of updating the same for cpeditor.

@ouuan
Copy link
Member

@ouuan ouuan commented Jun 8, 2020 •

Seems like need to make changes in https://github.com/Megaxela/QCodeEditor

You can add some codes around here:

https://github.com/cpeditor/QCodeEditor/blob/2139da3b44315043877fc85ca9719f3f7eac9c86/src/internal/QCodeEditor.cpp#L816-L821

When "}" is pressed, you can check whether the cursor has no selection and is at the beginning of the current line (all characters before it are whitespaces), and use QCodeEditor::unindent to unindent. Remember to make it optional.

You can ask us if you have any questions, and we'll help you to improve the codes when your PR is proposed.

Looking forward to your pull request!

@ouuan
Copy link
Member

@ouuan ouuan commented Jun 8, 2020

@allcontributors add @sahil-ra as a contributor for the idea.

@allcontributors
Copy link
Contributor

@allcontributors allcontributors bot commented Jun 8, 2020

@ouuan

I've put up a pull request to add @sahil-ra! 🎉

@sonulohani
Copy link
Contributor

@sonulohani sonulohani commented Jun 8, 2020

hen "}" is pressed, you can check wheth

Working on it. Thanks for the info.

@sonulohani
Copy link
Contributor

@sonulohani sonulohani commented Jun 12, 2020

I am able to implement this. But I need to store the previous position of the opening curly brace("{") to make it work more better which will take more time.

@coder3101
Copy link
Member

@coder3101 coder3101 commented Jun 12, 2020

You can open up a draft PR and we will review or suggest and help you in improving your changes.

@sonulohani
Copy link
Contributor

@sonulohani sonulohani commented Jun 13, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.