Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Adds directory names to the files in working tree, ... #4419

Merged
merged 16 commits into from
Aug 6, 2013
Merged

Adds directory names to the files in working tree, ... #4419

merged 16 commits into from
Aug 6, 2013

Conversation

zaggino
Copy link
Contributor

@zaggino zaggino commented Jul 11, 2013

... when multiple files with the same name are opened.

Any comments welcome.

myfix

@ghost ghost assigned larz0 Jul 11, 2013
@pthiess
Copy link
Contributor

pthiess commented Jul 11, 2013

@larz0 can you please review

@karllindmark
Copy link

I was literally going to fork the repo and implement this, but it seems like you got it covered @zaggino. :-)

@larz0
Copy link
Member

larz0 commented Jul 12, 2013

Looks good @zaggino, could we use "-" instead of "|", and use 11px font for the the directory class? Like the screenshot below:
screen shot 2013-07-12 at 10 45 28 am

This is great.

@larz0
Copy link
Member

larz0 commented Jul 12, 2013

Actually, use the em dash ("—" instead). Thanks.

@zaggino
Copy link
Contributor Author

zaggino commented Jul 13, 2013

No problem.

capture

@njx
Copy link
Contributor

njx commented Jul 15, 2013

Removing @larz0 as assignee since he's already reviewed it for UI design. We'll assign a reviewer or mark it [OPEN] soon.

@ghost ghost assigned larz0 and dangoor Jul 16, 2013
@peterflynn
Copy link
Member

@larz0 I think we'd want em dash only on Mac -- Windows uses a regular hyphen. See the titlebar, for example...

We should probably hoist up some sort of platform-specific separator constant from the current titlebar code in DocumentCommandHandlers.WINDOW_TITLE_STRING so it can be shared with the new code here.

@larz0
Copy link
Member

larz0 commented Jul 18, 2013

@peterflynn ok sounds good. #4303 could use that as well then.

@dangoor
Copy link
Contributor

dangoor commented Jul 30, 2013

@peterflynn I agree that not repeating that construct in DocumentCommandHandlers would be a good thing. Any opinion on where a separator constant should go? It's not l10n related, but it could go in strings.

@dangoor
Copy link
Contributor

dangoor commented Jul 30, 2013

@zaggino Sorry for the delay in looking at this. Things got a bit hectic during sprint 28.

The first thing that I noticed in looking at your changes is that they feel like the way an extension would do things: augmenting the working set after the core code has done its work. On the other hand, the other code for presenting items in the working set is concerned with the presentation of single items... adding duplicate tracking code to the existing working set view code would require redrawing previously drawn items in many cases. The approach you took may just be cleaner overall.

WorkingSetView-test has a reasonable collection of tests to build on. Would you be able to add some tests that exercise this functionality. At least one test that adds a duplicate file to the working set, causing two files to be displayed with the directory would be good.

If that test was then extended to remove one of the two duplicate files from the working set, I think you'd spot a bug where the directory name stays displayed for the remaining file. (At least, when I read through the code, that's what it looks like would happen... I haven't tested it yet.)

@zaggino
Copy link
Contributor Author

zaggino commented Jul 31, 2013

@dangoor Yes, you were right. I added a test for this and then fixed the problem, take a look please.

I also have a question - when I run tests in Brackets for the first time, they run from actual sources, which is fine. When I make some modifications to the tests, I need to restart Brackets before running tests again otherwise they seem to be running from some cached source. Am I doing something wrong? Surely it's not optimal to restart Brackets every time I write something into the tests.

@dangoor
Copy link
Contributor

dangoor commented Jul 31, 2013

@zaggino thanks for adding the test. I'll take a look at the code a bit later.

For running the tests without restarting, open the dev tools from the test runner window and click on the gear icon to pull up the settings. Click on Disable Caches there. (Annoying, I know! But, at least this is something you need only do once).

@dangoor
Copy link
Contributor

dangoor commented Aug 1, 2013

I don't want to complicate this too much, but I noticed that if you open test/node/package.json and src/extensibility/node/package.json they both list "node" as the directory. I'd be okay with that for a first go at this feature, but I thought I'd mention it in case you feel like fixing that :)

@dangoor
Copy link
Contributor

dangoor commented Aug 1, 2013

Overall, the code looks good, the test looks good. I appreciate the work you've done here!

@zaggino
Copy link
Contributor Author

zaggino commented Aug 1, 2013

That's a valid point and I actually thought of this one when I was first writing the code but wasn't really sure about the proper solution as different editors I have used in the past handle this different way. What do you think would be preferable? Show just first different directory there (this case would be 'extensibility' and 'test', I think eclipse does this) or keep adding parent directory names until strings are different (that would show 'extensibility/node' and 'test/node') ? I personally like the second option more but string could get very long in extreme cases of course. That could be solved that if there were many directories like a/c/d/e and b/c/d/e, middle common thing could be replaced to a/.../e and b/.../e. If I'll have a hint how the final thing should look like I have no problem implementing it.

@dangoor
Copy link
Contributor

dangoor commented Aug 1, 2013

Maybe @larz0 has an opinion on this, but I like your suggesting of keep adding directories until the strings are different. (FWIW, Sublime seems to show the different directories starting from the top... src/extensbility/node, test/node)

@zaggino
Copy link
Contributor Author

zaggino commented Aug 2, 2013

@dangoor take a look at new commits please. I used old style for cycles in the main algorithm to be as efficient as possible in this. Also been looking if it's possible to get into an infinite loop here, but I think that would require to have one file on the file system opened twice in the working tree, what should not be possible, right?
image

@dangoor
Copy link
Contributor

dangoor commented Aug 2, 2013

I just pulled the latest code from your branch and noticed three things:

  1. the case above is handled well!
  2. package.json at the top level is shown as "package.json –". I think that either just "package.json" or "package.json – /" would be better (I'm leaning toward "package.json". What do you think?)
  3. the new code seems to be kicking in all the time

For the third one above, I have node_modules/mathjs/package.json, src/extensions/dev/ex1/package.json and src/extensibility/node/package.json open. In this case, it should be able to just say "package.json – mathjs", "package.json – ex1" and "package.json – node".

package.json has been a good stress test for this, given how many of them there are :)

@zaggino
Copy link
Contributor Author

zaggino commented Aug 2, 2013

I'll definitely look at that third thing sometime over the weekend.

I don't really know between "package.json" and "package.json – /" ... First one would give me a feeling that the file was excluded from the functionality (and the current tests would fail if there was no .directory element next to it, when counting how many files were affected by this, but that could be of course fixed). Second one would make probably me wonder for a second or two (for the first time), where did the slash come from.

@zaggino
Copy link
Contributor Author

zaggino commented Aug 3, 2013

@TomMalbran I wanted to ask at least three times and always forgot, do you use any code-formatting tool ? I use jsbeautify in my projects before each commit so I don't have weird diffs in git, but that seems to mess-up a code here.

I fixed those JSLint errors and the last mentioned problem:
image

Also did the merge with current master (in two commits because I fucked up submodules in the first sadly).

@TomMalbran
Copy link
Contributor

I use Brackets, with JSLint enabled, and no other formatting tool.

It looks great now.

2 more minor things. We always use " instead of ' and \u2026 instead of ....
Here are the codding conventions: https://github.com/adobe/brackets/wiki/Brackets-Coding-Conventions

@zaggino
Copy link
Contributor Author

zaggino commented Aug 4, 2013

Fixed

@@ -89,6 +90,112 @@ define(function (require, exports, module) {
}

/**
* Adds directory names to elements representing passed files in working tree
* @private
* @param {Array.<FileEntry>} fileArray
Copy link
Contributor

Choose a reason for hiding this comment

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

Move the @private above the description.
Rename fileArray to filesList and add a description since it kinds of expects FileEntries with the same filenames. Would work with any array of FileEntries but will not do the same stuff.

@TomMalbran
Copy link
Contributor

Thanks for the fixes. I added a few more comments after going through the final code.

@TomMalbran
Copy link
Contributor

And there are a few more JSLint errors in WorkingSetView-tests.js.

CommandManager.execute(Commands.FILE_CLOSE)
.done(function () { didClose = true; })
.fail(function () { gotError = true; });
waitsFor(function () { return didClose && !gotError; }, "timeout on FILE_CLOSE", 1000);
Copy link
Contributor

Choose a reason for hiding this comment

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

You can replace from line 287 to line 291 with:
waitsForDone(CommandManager.execute(Commands.FILE_CLOSE), "timeout on FILE_CLOSE", 1000);

@zaggino
Copy link
Contributor Author

zaggino commented Aug 4, 2013

Comments in the code should be fixed, JSLint errors too.

@TomMalbran
Copy link
Contributor

Great, thanks. Will wait to see if @dangoor has something to add, since he is assigned to this PR.

There might still be the issue about using "-" for Windows and "—" for Mac, but could be fixed on separate issue too.

@ghost ghost assigned TomMalbran Aug 5, 2013
@dangoor
Copy link
Contributor

dangoor commented Aug 5, 2013

@TomMalbran thanks for diving in to this review. I've gone ahead and assigned it to you. If you think it's all set, go ahead and merge.

Thanks again @zaggino for continuing to push forward on this. I know things often don't end up being quite as quick and easy as we expect :)

@TomMalbran
Copy link
Contributor

@dangoor np. Looks good to me. Any suggestion as to what to do with the dash? I think we could add a dash string to nls/strings.js and use that string here and at the window title. Or we should make a new issue to fix it?

@dangoor
Copy link
Contributor

dangoor commented Aug 5, 2013

@TomMalbran let's take care of that in a separate issue that would make this code and DocumentCommandHandlers do the same thing.

@TomMalbran
Copy link
Contributor

@dangoor Sounds good. With #4303 Find in Files is also using a dash, which should be a normal one on windows and long on Mac. So if the dash is a String, it will probably be the best solution.

@TomMalbran
Copy link
Contributor

Everything looks great here. Merging :)

TomMalbran added a commit that referenced this pull request Aug 6, 2013
Adds directory names to the files in working tree, ...
@TomMalbran TomMalbran merged commit 0e7e0f5 into adobe:master Aug 6, 2013
@zaggino zaggino deleted the duplicate_filenames branch August 6, 2013 04:30
@zaggino
Copy link
Contributor Author

zaggino commented Aug 6, 2013

@dangoor @TomMalbran Thanks, this has been quite a good learning experience ;-)

@larz0
Copy link
Member

larz0 commented Aug 6, 2013

@zaggino this is awesome. Good job!

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

Successfully merging this pull request may close these issues.

8 participants