Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Feature/add bookmarks menu #2554

Merged
merged 10 commits into from
Sep 10, 2018
Merged

Conversation

akinsho
Copy link
Member

@akinsho akinsho commented Sep 6, 2018

This is largely inspired by perusing @CrossR's dotfiles a while ago and by the fact that FZF broke for me recently 😆, it uses the oni.bookmarks to generate a menu with submenus the idea being, the first menu represents the contents of oni.bookmarks e.g.

// folders are relative to the home directory or a users configured `oni.bookmarks.baseDirectory`

"oni.bookmarks": [".dotfiles", "Desktop/stuff"]

The first menu will have two items, hitting enter on any will go into the directory and render its content of files and folders, this can be repeated over and over for folders, if a user selects a file it will open it.

There is also a command (oni.bookmarks.setFolderOrOpenFile) that can be bound to set a folder to the active workspace so if a user e.g. was currently on .dotfiles/vim and hit the bound key it would make the folder the active workspace.

@CrossR
Copy link
Member

CrossR commented Sep 6, 2018

Excited for this!

This and a terminal selector are the things I use most that I've added myself, so glad to see it being added properly! If I can swap my terminal selector to be entirely in Oni (and not half in Oni half in my Vim config), I'll try adding that too.

@codecov
Copy link

codecov bot commented Sep 6, 2018

Codecov Report

Merging #2554 into master will increase coverage by 0.38%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2554      +/-   ##
==========================================
+ Coverage   44.93%   45.31%   +0.38%     
==========================================
  Files         352      353       +1     
  Lines       14336    14427      +91     
  Branches     1863     1885      +22     
==========================================
+ Hits         6442     6538      +96     
+ Misses       7669     7666       -3     
+ Partials      225      223       -2
Impacted Files Coverage Δ
browser/src/Services/CommandManager.ts 50% <100%> (+1.21%) ⬆️
browser/src/neovim/VimHighlights.ts 28.57% <0%> (-46.43%) ⬇️
browser/src/Services/TokenColors.ts 57.14% <0%> (-12.86%) ⬇️
browser/src/neovim/NeovimTokenColorSynchronizer.ts 78.84% <0%> (-5.94%) ⬇️
browser/src/Editor/NeovimEditor/markdown.ts 13.58% <0%> (-0.35%) ⬇️
browser/src/UI/components/QuickInfo.tsx 75.6% <0%> (ø) ⬆️
browser/src/UI/components/common.ts 94.52% <0%> (ø) ⬆️
...ser/src/Services/SyntaxHighlighting/TokenScorer.ts 97.22% <0%> (ø)
browser/src/UI/components/Tabs.tsx 77.86% <0%> (+1.63%) ⬆️
browser/src/UI/components/QuickInfoContainer.tsx 33.33% <0%> (+2.56%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af03770...41fb8e6. Read the comment docs.

@akinsho
Copy link
Member Author

akinsho commented Sep 7, 2018

@CrossR would be good to get your feedback on the approach I took, I basically wanted the versatility to set add a bookmark dir and traverse it a little so that you could say set the Desktop as a book mark then move downwards set a subfolder as a workspace and the move downwards still and open a specific file in the subfolder to open which means it doesnt just do a search downwards through all subfolder but instead shows the top level then you can choose to go deeper and search there.

@CrossR
Copy link
Member

CrossR commented Sep 7, 2018

One thing I would quite like (though I'm biased since its what I currently use), is some form of wildcard selection of folders.

That way I can have a bookmark of ~/git/* say, and then every project in my git folder is a bookmark, rather than me needing to remember it.

Obviously with the 2 menu way, I can just set the Git folder as the bookmark and then select my project from the second menu, but having it work straight from the first menu would be nice.

The other thing would be the second menu would be more useful (to me at least) if it listed all files rather than just the top level directory. My general workflow is swap project > quickopen for the file/files I need. Maybe have an option to auto open the QuickOpen menu and nothing (for people who want to make a new file etc) instead of the second bookmark menu? That then supports three workflows:

  • Opening a bookmark and going deeper (current).
  • Opening a bookmark and grabbing a file (open QuickOpen menu).
  • Opening a bookmark only (open nothing for the second menu).

That said, there is also times I have wanted something like the second menu to focus the quick open in to a specific folder if I know I don't need anything from the other folders. Perhaps we could add a second command to open up the second menu directly for the current folder, such that if a user did want to restrict the current workspace, its easy to do so?

@akinsho
Copy link
Member Author

akinsho commented Sep 8, 2018

@CrossR actually looking through the code base I might be duplicating functionality I just saw

class BookmarkSearch implements IAsyncSearch {
seems its already partially implemented not sure how to use/access it though? @TalAmuyal would you know what that section of the code base does and if we can use it to surface a bookmarks menu?

@akinsho
Copy link
Member Author

akinsho commented Sep 8, 2018

Had a look and seems I've definitely done a bit of duplication 🤣 I'll switch to using our implementation in quickopen but seems it needs some beefing up anyway so not a complete loss

@akinsho
Copy link
Member Author

akinsho commented Sep 9, 2018

@CrossR I've decided to scope this down quite a lot since I spent quite a lot of time duplicating functionality we already had (my fault for not checking) atm I've basically hooked back up the menu we had which offers the user choices to open a folder, open a configuration file, and otherwise lists the bookmarks.

if the bookmark is a file it opens it if it is a dir it sets it to the active workspace.

I tried getting the quickOpen to auto open if the user selects a bookmarked dir but for reasons I cant decipher that doesnt work at all, there must be some block Im not seeing but tbh I think re. time and attention spread across too many PRs Id rather just scope this down to reactivating/activating the menu we have and slightly tidying up its functionality.

Re. globs I found a library that can read globs which might be useful for more than just this usecase its called node-glob, in case anyone finds this and wants to look into using it but think I'm gonna need to time box my efforts on it for now

@CrossR
Copy link
Member

CrossR commented Sep 9, 2018

Makes sense! I'll give it a try and we can add globbing later perhaps. Since I've asked for it, I'll have a look, and also compare it to other editors to see how they achieve it.

Just about to checkout the ligatures stuff, then will re-review this.


private _getBookmarkPath = (bookmark: string) => {
const userBaseDir = this._oni.configuration.getValue<string>("oni.bookmarks.baseDirectory")
const baseDir = userBaseDir || homedir()
Copy link
Member

Choose a reason for hiding this comment

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

I think if there isn't "oni.bookmarks.baseDirectory" defined, then we should default to nothing?

Could cause confusion where I tried setting a bookmark of F:\User Files\Documents\Git\oni, which was resolved to C:\Users\ryan\F:\User Files\Documents\Git\uni_work.

Or, could leave this for now and in a follow up PR improve the logic here to be:

  • If relative, use base path (either defined, or home dir)
  • If absolute, use that always regardless of the value of "oni.bookmarks.baseDirectory".

I don't mind doing that (along with the globbing), or its also a pretty simple change so we could leave it as a "first issue"?

If you'd rather do that, then I can accept the PR in its current form, since the rest of it works great!

Copy link
Member Author

@akinsho akinsho Sep 10, 2018

Choose a reason for hiding this comment

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

@CrossR tweaked this to use the absolute path if absolute and relative resolves from a base dir

Copy link
Member

@CrossR CrossR left a comment

Choose a reason for hiding this comment

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

Thanks for making that change, looks good!

@akinsho akinsho merged commit e6595e6 into onivim:master Sep 10, 2018
@akinsho akinsho deleted the feature/add-bookmarks-menu branch September 10, 2018 10:54
@akinsho akinsho restored the feature/add-bookmarks-menu branch October 1, 2018 09:36
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.

2 participants