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

Add the ability to collapse nodes in the outline for XML. #59

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

burtnoir
Copy link

This change allows the user to click on an icon to the left of the node to collapse the children of that node - much like in the file tree. It allows you to close an inner node then open and close an outer one without affecting the state of the inner set.
The one thing I wasn't sure about was my change in _getIndentationLevel - it's a bit severe but I was having problems when browsing a document with different indentation than my editor settings so I decided to simplify things and rely on the actual indentation in the document.

}
whitespace = whitespace.replace(/\t/g, tmpSpaces);
return (whitespace.length / indentSize) | 0;
return whitespace.length;
Copy link
Owner

Choose a reason for hiding this comment

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

The indentation seems off here.

@Hirse
Copy link
Owner

Hirse commented Feb 16, 2016

Thanks for your PR.
I really like this idea. 😄

Could you give some more explanation as to why you changed the _getIndentationLevel function because based on some quick tests it works fine for me even with mixed indentation styles?

@burtnoir
Copy link
Author

Thanks for looking at this one so quickly. Sorry for all the indentation issues, I was editing and testing out different indentations at the same time which wasn't the best idea :) I'll sort that stuff and the inline function out later this evening.

I was looking at a sample XML that had indentation of three spaces and then I had Brackets set to a tab size of 4 (from memory) and it resulted in no indentation for the first indent level. No indentation means no icon and so you can't collapse. Here is the file:
sample.txt

I will give this one some more thought to see if I can come up with something better. In general I guess it needs to handle edge cases where the editor indent size is greater than the document's indent.

@burtnoir
Copy link
Author

I think I dealt with the indentation and the inline. It's late here now so I'll look at the _getIndentationLevel change tomorrow.

@Hirse
Copy link
Owner

Hirse commented Feb 17, 2016

Thanks for your effort.

Generally, I don't think this extension has to handle indentation problems.
We should be safe to assume a valid document and an indentation that equals the Brackets settings.

And btw, to detect and automatically set the indentation I have another extension:
https://github.com/Hirse/brackets-detect-indentation

@burtnoir
Copy link
Author

That sounds fair - I'll revert the indentation stuff when I get home. And I'll be sure to check out the other extension :)

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.

None yet

2 participants