-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support unusual characters in file and directory names #868
Conversation
I don't know what I was thinking. The delimiter doesn't need to be used to separate every indicator on the node's text, ie. Bad: Tree|GenericFlags|Filename|ExecutableFlag|Link|ReadonlyFlag Better: Tree GenericFlags|Filename|ExecutableFlag Link ReadonlyFlag This was unnecessary, given that we're only interested in the filename. So, just one pair of delimiters is all we need. That greatly simplifies the _stripMarkup function, and restores a bunch of other statements to what they already are in the master branch.
Wow, Phil! You've been busy. I'll make sure to take a look at this this week! |
This is probably the best we can do, especially if some other character must be used in place of nbsp.
It was allowing 2+ spaces, instead of only 1+.
@lifecrisis , did you get a chance to review this yet? I'm going to start tagging the issue authors for their help in reviewing this too. |
So far, doesn't seem to have fixed #555 |
It fixes #680 🎉 |
@PhilRunninger fixes #555 ! |
Using ':' as a more visible delimiter, when directories are cascaded, the line appears in NERDTree like so: ▾ :lib/::nerdtree/: Before this commit, the s:UI._stripMarkup function was leaving the internal delimiters in place (lib/::nerdtree/). Now they are removed, resulting in a valid path (lib/nerdtree/).
@lifecrisis , your observation has been addressed. Take another look. Thanks. |
It seems that the functionality is all there! Awesome! I still want to take a closer look at the code itself, so I'll try to make it happen later this week. This is a pretty high-impact change! |
I'm getting hung up on something small here... Go to the line of any NERDTree node. Press |
I also noticed that, now, I can move the cursor beyond the end of the line. I.e., I can move the cursor to the trailing nbsp character. I think I have a solution to this... Instead of relying on concealing the character, just show the first nbsp character and only use the second one if there are trailing flags (by having the process for appending the flags also add the nbsp first). This would mean that a node would be delimited like Also, just curious, how are we determining that nbsp is even available in the user's context? What is the likelihood that this character will be available? Is it almost certain? |
@lifecrisis , I tried implementing your solution, but I think I'll stick with what's committed already. On filenames and single directories, there are no issues, and I can parse them easily. Here are some examples: (A colon is used in place of the nbsp below.)
However, when dealing with cascaded directories, we have this situation.
There is no easy way to distinguish the intermediate I think the cursor's "catching" on the leading nbsp, and moving beyond the node where the trailing nbsp is, are minor issues, as horizontal movement isn't really needed (and probably uncommon) in NERDTree. Whether nbsp is available in all fonts is a mystery. I have no way of knowing for sure, but I'd guess it fairly likely is. That being said, since it's being concealed anyway (concealing requires 7.3+), it shouldn't really matter how that character is rendered. |
Ever thought about just associating each node with the line number it's written on though a Vim dictionary? Then we could just render each node as we please. The dictionary could be updated every time the NERDTree is drawn. Is this crazy? I'd be worried that that process might become slow for large directories. EDIT: The efficiency issue could possibly be solved by giving each node a unique integer identifier that we can use as a reference. |
I like that idea. It would take some time to get everything right, and performance could be a problem, but we won't know if we don't try. What do you suggest?
|
It's a pretty complicated idea... I'll have to think about it for a bit. |
I thought about what you wrote above:
I'm not sure why you need intermediate nbsp characters... the NERDTree directory separator is always the I'm not really following the thinking here. Sorry if I'm just confusing myself... |
Assuming we use the trailing nbsp only when adding the The nodes are separate objects in memory, so each dir node would have the leading delimiter.
but when they are combined for cascading, they look like this
This is the behavior you noticed in this comment above. (Remember, at that time it would have been Getting rid of the leading nbsp and everything before it is easy, but if we blindly get rid of the last nbsp and everything after it, we could end up losing the last folder of this cascaded directory node.
So it's a specific case of cascaded directories and no tags that causes the suggested fix to fail. I just thought of a way to make this work. The code that combines the parent and child directory nodes can strip the leading nbsp off each child directory. I haven't looked at the code to see if it will work, but I think that's the way to go. |
That's exactly what I meant! I feel like I'm being a bit difficult on this issue, but I'm adamant that this is something we need to get right. It's such a fundamental change, and it would be very useful. (Nice GIF by the way.) Perhaps we could go with node ID numbers, associative arrays, etc., in the next version of the NERDTree and just use this for now (you're only affecting a few dozen lines of code here). |
* If flags are needed after the node name, then put another delimiter before them. * When joining directory nodes for cascaded display, strip off the delimiter from the child node(s). * Remove the unnecessary substitution of doubled intermediate delimiters, since they're not in there anymore.
No worries. I'm glad to have you reviewing this. It results in a much better solution that way. New commits (final ones, I hope) coming soon. |
@lifecrisis , that should just about do it. Take a look and let me know. |
Fixes: #680 #492 #469 #424 #391 #217
This PR has the potential to fix a bunch of issues. The problem with these issues is related to parsing the file or directory name from the current line of text. In short, I fixed it by surrounding the filename with non-breaking spaces (ASCII code 160), and using that pair of delimiters to find the filename in the text when needed. I also added syntax highlighting to conceal this character, making it appear as if nothing has been added. The advantages to using this character are:
conceal
is not compiled into your Vim, the only side effect is that the tree and trailing flags are pushed over by one extra "space".There may be cases where this doesn't work so well, though, and some improvements will need to be made to this PR. The one I can think of right away is editing in an environment that doesn't support Unicode characters, or whatever the non-breaking space is.
ssh
comes to mind as a possible trouble spot.conceal
was added in 7.3, but with theif has("conceal")
in the syntax file, we should be ok. It will just have the added spacing indicated above.I would like to enlist the authors of the related issues to test this fully. Areas I'd like them and others to try are:
Of course, I don't expect everyone to test all these areas, but given enough people we can likely cover them all.