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

Place before namespace if no include found #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

m42e
Copy link

@m42e m42e commented Dec 17, 2015

In case you use this in header files, it would be better to look for a
namespace declaration then putting it on top, where the guard header
should be.

@@ -122,6 +122,8 @@ module CppAutoInclude
VIM::lines.each_with_index do |l, i|
if l =~ /^\s*#\s*include/
includes << [l, i+1]
elsif l =~ /^\s*namespace/ and includes.length == 1
includes << ['', i]
Copy link
Owner

Choose a reason for hiding this comment

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

Just change the line number of the place holder:

includes[0][-1] = i

This will save some bytes especially when there are multiple namespaces

@quark-zju
Copy link
Owner

Nice catch 😃 Thanks!

In case you use this in header files, it would be better to look for a
namespace declaration then putting it on top, where the guard header
should be.
@m42e m42e force-pushed the include_placement branch from 8600479 to e0aae75 Compare December 18, 2015 06:47
@m42e
Copy link
Author

m42e commented Dec 21, 2015

Done, even if I didn't really get what is happening there ... :D I'm not to familiar with ruby

@m42e
Copy link
Author

m42e commented Apr 19, 2016

would you mind merging the pull requests?

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

Successfully merging this pull request may close these issues.

2 participants