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

Folders from path #43659

Merged
merged 9 commits into from
Feb 19, 2018
Merged

Folders from path #43659

merged 9 commits into from
Feb 19, 2018

Conversation

tsalinger
Copy link
Contributor

fixes #31305
fixes #9349

- text-overflow handled by elliipsis appearing at the beginning of path
- adds word-wrap to inputBox messages
- adds whether file or folder is going to be created
@isidorn isidorn added this to the February 2018 milestone Feb 16, 2018
/**
* Determines whether the ellipsis appears at the left or right side of the string
*/
export enum EllipsisType {
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not seem to be needed anymore. Same as IShowMessageOptions

@@ -392,6 +406,7 @@ export class InputBox extends Widget {
const styles = this.stylesForType(this.message.type);
spanElement.style.backgroundColor = styles.background ? styles.background.toString() : null;
spanElement.style.border = styles.border ? `1px solid ${styles.border}` : null;
spanElement.style.wordWrap = 'break-word';
Copy link
Contributor

Choose a reason for hiding this comment

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

- removes unused interface and enum for ellipsis
@@ -136,6 +136,33 @@ suite('FileService', () => {
}, error => onError(error, done));
});

Copy link
Contributor

@isidorn isidorn Feb 16, 2018

Choose a reason for hiding this comment

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

@tsalinger I do not really understand why you added new tests in the fileService, when this feature does not touch anything inside the fileService as far as I understand
@bpasero can you please review if these tests are needed in the fileService

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are exploratory tests that I wrote to test whether I can implement this feature the way I did.

}
}

function replaceWithNativeSep(str: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be a helper method in paths.ts so you do not need to introduce a new one. Try using what we alerady have.

@@ -296,6 +296,7 @@ export class FileRenderer implements IRenderer {
}, 0);
});

const initialRelPath: string = relative(stat.root.resource.fsPath, stat.parent.resource.fsPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

You only use this const further down. It is usually best to intiilize things exactly where you use them so they are scoped in the right place, please move it to the place where you actually use it.

@@ -1335,35 +1336,77 @@ export function validateFileName(parent: IFileStat, name: string, allowOverwriti
return nls.localize('emptyFileNameError', "A file or folder name must be provided.");
}

const names: string[] = trimTrailingSlashes(name) // prevents empty last array element after split
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove trimTrailingSlashes ,just split go through the array and filetr out null elements. Like this
name.split(/[\\/]/).filter(part => !!part);
imho that is simpler

return nls.localize('filePathTooLongError', "The name **{0}** results in a path that is too long. Please choose a shorter name.", trimLongName(name));
}
}

return null;
}

function windowsMaxLengthRestrictionReached(name: string, parent: IFileStat): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not understand what is hte benefit of adding this function. It is the same functionality as before but now it is enapsulated in a function, but we still call the function only once.
Imho a best PR is when it contains the minimal changes need to make it happen, so I would remove this helper function

return { exists: false, child: undefined };
}

function compareFolderNames(name1: string, name2: string): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not really see the benefit of moving the folderName comparison to a seperate method. I would keep it as it iwas before, especially since compare functions usually return -1, 0 and 1 so for me this is confusing naming since it returns a boolean. If it returns a boolean it shoulld be areFolderNamesEqual. Though I prefer not having a method

if (parent.children) {
let exists: boolean = parent.children.some((c) => {
let found = compareFolderNames(c.name, name);
if (found) { foundDupChild = c; }
Copy link
Contributor

Choose a reason for hiding this comment

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

We try to format our if statements that they body of the if is always in the new line, even if it is a single statement

}

function alreadyExists(parent: IFileStat, name: string): { exists: boolean, child: IFileStat | undefined } {
let foundDupChild: IFileStat;
Copy link
Contributor

Choose a reason for hiding this comment

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

duplicateChild might be a better name, this way it sounds like a boolean

@@ -316,6 +320,27 @@ export class FileRenderer implements IRenderer {
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this should not be a function, either a lambda expression or a private method in the explorerViewer. Though if you prefer functions we can leave it this way

@isidorn
Copy link
Contributor

isidorn commented Feb 16, 2018

@tsalinger I have added some comments. Feel free to push, and just ping me here once you address what you feel like needs addressing.
Once that is done I will try it out again and we can merge this in

Nice work 🍻

- displayCurrentPath: file/folder not bold anymore
@isidorn isidorn merged commit 46101da into master Feb 19, 2018
@isidorn isidorn deleted the foldersFromPath branch February 19, 2018 10:16
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
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.

Creating multiple sub folders at once Allow to move a file by adding path segments to rename box
2 participants