Repository navigation
support search and jump - #1
Conversation
|
@fxha There still some bugs, for example, if we search ```javascript, we click the search result, but it will break the render content of the search result file. Maybe I'll handle it after your PR merged or before. |
| const nextLine = cm.getLine(cursor.line + 1) | ||
| cursor = adjustCursor(cursor, preLine, line, nextLine) | ||
| return { cursor, markdown } | ||
| const adjCursor = cursor => { |
There was a problem hiding this comment.
Yeh, as I comment in this PR, we need to adjustCursor the cursor which get from the search results. Because we can not always find a correct position in preview mode according by the search results.
So, Can we get the previous line and next line of search result line?
There was a problem hiding this comment.
I think this is not a problem and when searching e.g. for a code block we can safely jump into the next line or code block content. I think it's not a big problem and sufficient to correct find raw text matches but the given cursor from ripgrep may be also invalid due files changes.
Did you tested search of an image link/test?
There was a problem hiding this comment.
Did you tested search of an image link/test?
No, ripgrep can search in the image link, but preview mode didn't support search in the image link any more, maybe we can just scroll to the image, and select the image, when click the search result.
There was a problem hiding this comment.
I found another issue, ripgrep search on the disk, but Mark Text maybe not save the markdown content immediately to the disk. So the click search result the cursor maybe not found in the already not saved tab.(You already mentioned bellow)
There was a problem hiding this comment.
maybe we can just scroll to the image, and select the image, when click the search result.
That's actually a good idea/improvement.
I found another issue, ripgrep search on the disk, but Mark Text maybe not save the markdown content immediately to the disk. So the click search result the cursor maybe not found in the already not saved tab
Please see below.
fxha
left a comment
There was a problem hiding this comment.
vue.esm.js?a026:1897 TypeError: Cannot read property 'substring' of undefined
at ContentState.addCursorToMarkdown (importMarkdown.js?4b04:428)
at Muya.setMarkdown (index.js?64a7:147)
at VueComponent.eval (editor.vue?7b20:654)
at Array.eval (vue.esm.js?a026:1989)
at flushCallbacks (vue.esm.js?a026:1915)
when you remove a few lines from the opened tab and click on a search result that match line > current tab lines or the file length on disk is less than the match line.
E.g. Search for foo and the result is in line 3. Click on the result and the file is opened and selected on line 3. Now remove all content except line 1 and click again on the search result line 3.
|
I would consider Regarding changed tabs and find in files: I think the easiest fix would be to correct invalid parameters in muya. E.g. when we try to open line 4 but the file on disk/opened tab only has 2 lines then line 2 should be selected and also the same for an invalid offset, select the best offset or position 0. |
|
Otherwise, this PR is merged first, then I submit an issue in marktext/marktext, and I am trying to fix the problem that the cursor may not find. |
* Add ripgrep as find in files backend * Fix API limit on Appveyor * Fix css style * support search and jump (#1) * Style fixes
Support jump to cursor position by click search result in side bar.
This change is