Skip to content

Add ripgrep as find in files backend - #1086

Merged
Jocs merged 6 commits into
marktext:developfrom
fxha:ripgrep
Jun 20, 2019
Merged

Jocs merged 6 commits into
marktext:developfrom
fxha:ripgrep

Conversation

@fxha

@fxha fxha commented Jun 9, 2019 •

Copy link
Copy Markdown
Contributor
Q A
Bug fix? yes
BC breaks? yes
Deprecations? yes
Fixed tickets #1034
License MIT

Description

  • Added ripgrep as find in files backend
  • Added searcher and watcher settings
  • Improved find in files view UI
  • Reduced memory usage when opening a (lage) directory: 200MB after GC (400MB) now vs 600MB/900MB after GC (1,3GB) before - tested on vscode source code.
    • Improved open directory time and CPU usage by not render sub-trees.
    • Removed the markdown content in tree that was stored for each markdown file on disk.
    • Only show markdown files and directory in tree view.
  • Removed second side bar "files" view that shows all markdown documents.
  • Some theme tweaks

mt_find_in_files

Missing things:

  • Muya don't supports to set cursor at a specified line + offset. Open issue about muyas cursor range API.
  • Improve find in files and tree by not rendering elements out of screen.
  • Improve tree view data structure.

resolves #554
resolves #1034
resolves #1026

@fxha
fxha requested a review from Jocs June 9, 2019 13:55
@fxha

fxha commented Jun 9, 2019

Copy link
Copy Markdown
Contributor Author

@Jocs Do you know why karma tries to load the LICENSE file in src/renderer/assets/icons/searchIcons and how to prevent this?

Comment thread src/muya/lib/assets/styles/index.css Resolved
--buttonPrimaryBgColor: var(--themeColor);
--buttonPrimaryBorder: none;
--buttonPrimaryShadow: none;
--buttonPrimaryFontColorHover: var(--buttonPrimaryFontColor);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With so many CSS variables, can we not reduce it? Because the fewer variable names, the more convenient it is for users to customize the theme in the future. Too many variables can be confusing for users.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it would be easier to write themes. E.g. the one-dark theme used a lot of overwrites that need to be updated each time we change a bit of GUI. With variables it's much easier to maintain a theme without breaking it after an update.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I still think that too many variables are not good for maintenance, nor is it a best practice. If you want to reuse styles, we can define some common classes, such as btn, size-small, primary, error, etc. instead of defining so many variables. name.

@Jocs

Jocs commented Jun 9, 2019

Copy link
Copy Markdown
Member

屏幕快照 2019-06-09 下午11 56 17

The button color is wrong, it's too brightness.

Comment thread src/renderer/assets/styles/index.css Resolved
Comment thread src/renderer/components/search.vue Resolved
@Jocs

Jocs commented Jun 9, 2019

Copy link
Copy Markdown
Member

Improved open directory time and CPU usage by not render sub-trees.

How is this done? I didn't find the relevant code.

@Jocs

Jocs commented Jun 9, 2019

Copy link
Copy Markdown
Member

Do you know why karma tries to load the LICENSE file in src/renderer/assets/icons/searchIcons and how to prevent this?

I didn't see karma loading this file, where did I see it? Can you take a screenshot?

@Jocs

Jocs commented Jun 10, 2019

Copy link
Copy Markdown
Member

Muya don't supports to set cursor at a specified line + offset.

I am working on this now, and will submit a PR to you ripgrep branch as soon as possible.

@fxha

fxha commented Jun 10, 2019

Copy link
Copy Markdown
Contributor Author

The button color is wrong, it's too brightness.

I have not changed anything on Element UI but there are more wrong colors. If you mean the left down arrow background and color that's because it's disabled (2 is the minimum value) but this is the same as in v0.14.0.

How is this done? I didn't find the relevant code.

I replace v-show with v-if somewhere in tree.

I didn't see karma loading this file, where did I see it? Can you take a screenshot?

This was an issue with the main karma file that included all src/renderer files. I fixed it by only include js and vue source files.

@Jocs

Jocs commented Jun 10, 2019

Copy link
Copy Markdown
Member

but this is the same as in v0.14.0.

My fault, it's the same. we can optimize it later.

@Jocs

Jocs commented Jun 13, 2019

Copy link
Copy Markdown
Member

@fxha I added a GITHUB_TOKEN to Travis CI, Do you know why it still failed?

@fxha

fxha commented Jun 13, 2019 •

Copy link
Copy Markdown
Contributor Author

Did you tested/build this branch on macOS? I actually don't know why macOS download fail but Linux not. According to Travis documentation macOS instances are hosted with another IP range, maybe this is blacklisted by GitHub?

@Jocs

Jocs commented Jun 13, 2019

Copy link
Copy Markdown
Member

Did you tested/build this branch on macOS?

I'll try it later and tell you the result.

@fxha

fxha commented Jun 13, 2019

Copy link
Copy Markdown
Contributor Author

I just restarted Linux build and got Request failed with code 403 download error.

@fxha

fxha commented Jun 13, 2019 •

Copy link
Copy Markdown
Contributor Author

I think the issue it that the secret environment variables are only decoded when building from marktext/marktext branches but not from fork PRs for security reasons. Theoretically I'll have to open this PR from the original marktext branch, successfully build and cache the binary to successfully pass further PRs. I'll test this later or tomorrow on a testing branch + dummy PR - or we would need to manually build ripgrep.

@Jocs

Jocs commented Jun 13, 2019

Copy link
Copy Markdown
Member

. I'll test this later or tomorrow on a testing branch + dummy PR -

Good idea.

@Jocs

Jocs commented Jun 13, 2019

Copy link
Copy Markdown
Member

I'll try it later and tell you the result.

I run yarn test and yarn build on macOS system based on this PR, it passed all and no error happened.

@fxha fxha mentioned this pull request Jun 13, 2019
@fxha

fxha commented Jun 13, 2019

Copy link
Copy Markdown
Contributor Author

@Jocs Yeah it's an issue with PRs and secret environment variables, my test branch and PR passed. Shall we merge this PR when ready or should I cherry pick the commits onto marktext repository?

@Jocs

Jocs commented Jun 14, 2019

Copy link
Copy Markdown
Member

Shall we merge this PR when ready or should I cherry pick the commits onto marktext repository?

I'll review it today. then we can ignore the CI failure and merge this PR.

Comment thread appveyor.yml Resolved
Comment thread src/main/windows/editor.js Resolved
Comment thread src/muya/lib/assets/styles/index.css Resolved
Comment thread src/renderer/assets/styles/index.css Resolved
--buttonPrimaryBgColor: var(--themeColor);
--buttonPrimaryBorder: none;
--buttonPrimaryShadow: none;
--buttonPrimaryFontColorHover: var(--buttonPrimaryFontColor);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I still think that too many variables are not good for maintenance, nor is it a best practice. If you want to reuse styles, we can define some common classes, such as btn, size-small, primary, error, etc. instead of defining so many variables. name.

@fxha

fxha commented Jun 15, 2019

Copy link
Copy Markdown
Contributor Author

I still think that too many variables are not good for maintenance, nor is it a best practice.

The main problem here is that we have to override all default themes (cadmium) values and this in all other themes. For sure we can c&p the basic buttons for each theme and set all other values to none.

@Jocs

Jocs commented Jun 15, 2019

Copy link
Copy Markdown
Member

Do we need to research the keyword after the we modify the edit content and autoSave is true?

@fxha

fxha commented Jun 16, 2019

Copy link
Copy Markdown
Contributor Author

Do we need to research the keyword after the we modify the edit content and autoSave is true?

This is definitely an improvement but for now I think this should be handled by muya - check for invalid selection range.

@Jocs

Jocs commented Jun 16, 2019 •

Copy link
Copy Markdown
Member

This is definitely an improvement but for now I think this should be handled by muya - check for invalid selection range.

I think they are two problem, yes, muya need to validate the cursor/selection after click the search result and navigate to the search result text in document/markdown file.(I'll open an issue about this, and fix it later.)

Another problem is, if we delete some content, or even delete all the content of current edit file, we modify the content on disk, the previous search results is not correct, so we need to do another search with previous keyword?

@Jocs
Jocs merged commit 7270242 into marktext:develop Jun 20, 2019
@fxha
fxha deleted the ripgrep branch June 22, 2019 10:37
@fxha

fxha commented Jun 22, 2019

Copy link
Copy Markdown
Contributor Author

@Jocs If you want to fix this you can remove and insert the new search result after a change for the changed file but not the whole root directory because this may be the home directory or another large folder. But I don't see a big problem with this because files on disk may change also. If muya can catch the invalid range issues etc everything should be ok, not like now that the editor may crash completely.

@Jocs

Jocs commented Jun 22, 2019

Copy link
Copy Markdown
Member

Yes, I'll handle the invalid cursor position before the next release version.

Jocs pushed a commit that referenced this pull request Aug 7, 2019
* Add ripgrep as find in files backend

* Fix API limit on Appveyor

* Fix css style

* support search and jump (#1)

* Style fixes
thimbleberrysystems pushed a commit to thimbleberrysystems/WordBird that referenced this pull request Jun 21, 2026
* Add ripgrep as find in files backend

* Fix API limit on Appveyor

* Fix css style

* support search and jump (marktext#1)

* Style fixes
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.

Refactor: Find in files Highlight search result and provide a straight jump File Tree - Filter Openable Files

2 participants