-
Notifications
You must be signed in to change notification settings - Fork 257
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
add search function for source code was: cache source code in vector for easier access in search function #470
Conversation
2c448e5
to
14e52cb
Compare
I thought that was by design, to ensure the syntax highlighting is correct? how does this behave when we have code like
|
The debuginfos mark the line with I thought about adding some logic to detect the start of the declaration, but there are too many edge cases to correctly detect this. The logic also would only work for C / C++ and would likely break if some other languages are used. |
This style is pretty common, and would then break, or?
Exactly, which is why I actually like the old approach of just highlighting the full file. it's not that slow, or? |
I commonly have to wait around 5 seconds (small programs) to 30 seconds (big ones) - not tested so far with huge ones. I personally don't see this as a big issue (other then #468 and much more #457 which do solve big issues I nearly always stumble over when working with hotspot). I'd be most concerned what this change means to inline functions and functions that heavily use macros. |
45f430b
to
9ac0bb0
Compare
Testing with current appImage yields in console flooded with "HSV parameters out of range" when hovering over the source code. |
that's weird. It should need more than a few milliseconds (my machine has no problem highlighting a file with 4.4 million lines in less than a second). Can you send us an example so we can profile this?
That's even weirder since the parameters a clamped to the allows range. |
Note that I'm using the appimage only which is currently limited to xcb - do you have this nice highlighting performance (and included disassembly) in less than a second using an appimage, too? [note: the big files I've tested were all over network - client with xserver, server "in the cloud", I guess that's the main reason for the performance I've seen]. ... but if huge files take less then a second, how is the original point of this PR
an issue? |
that doesn't brake syntax highlighting. It also resists
|
I didn't really profile this but it seemed that highlighting a file with 1000+ lines to show a function with 10 lines. But now I feel stupid for spending time on something that has a negligent impact on performance. Does this patch help in your case? |
Rechecked: With both CI builds 49 (current from this PR) and 50 (current from master) it takes ~27 seconds to open the disassembly on a "bad" sample with visible text. With master I've then seen ~1 second then the black text gets colored, with this PR it was nearly instant after the black-only text - but the ~27 seconds before coloring were identical. As noted: I think the issue is xcb from "cloud" to local xserver. |
I think the "slowness" is not that bad for the highlighting of the complete file. |
9ac0bb0
to
37f5a8d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two minor nits, otherwise lgtm
uhm did you push the wrong branch to this review? the discussion we had here doesn't match the code I just reviewed, or? |
I removed some stuff since it didn't work as expected. |
2855c1f
to
fce8558
Compare
just tested the current AppImage - Search works fine in general but I did not found a way to enable search other than CTRL+F, ideally there is a GUI option to start that - and ideally the same function also enables to "close" the search bar. One "gotcha": the current version never outputs a "no (more) occurence(s) found" mesage - instead clicking on "search" just goes to the next line. I guess that would be much less useful for most people - but waht about an optional search bar for the assembly window? |
Thanks, I completely forgot the buttons.
That would be interesting with the keyboard shortcuts. Will see what I can do about them. Probably something like mouse is above disassembly -> disassembly search otherwise source code search. |
Either that or simply have: CTRL+F-> code search; CTRL+SHIFT+F -> disassembly search. |
no, we should search in the focused widget via the correct shortcut context, and let the user use Tab to switch focus as needed |
agreed in principle - but can we then please:
Background: the tab key switches between every control which includes, additional to those three:
BTW: CTRL+F doesn't position to search in timeline currently |
src/models/sourcecodemodel.cpp
Outdated
? (m_sourceCodeLines.begin() + offset) | ||
: (m_sourceCodeLines.end() - (m_numLines - offset - 1)); // 1 one due to offset of the reverse iterator | ||
|
||
auto it = direction == Direction::Forward |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this code here could be greatly clarified by hoisting it into a function that takes the range as iterators and returns a result index (or -1 if nothing is found).
then you call that with either forward or backward iterators. my hunch is that the code would be much more readable then since you'd only have to take care of the direction when calling the function, but not inside it.
anyhow, leave it as-is for now, I'll try to clean it up myself then
I think what you are looking for here, besides proper tab order (which is probably not a given, have to double check): ALT-modifiers to trigger quick focus changes. That way, you could press |
This makes implementing a search much easier since we don't have to query a QTextDocument
there is no need to call this for every line since this is called on per symbol basis
4cae95e
to
06991bd
Compare
e5e2bfb
to
f048b95
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be cool if you can add the missing typeinfo and then submit it
f048b95
to
e4e88ea
Compare
I updated the SourceCodeModel to only include the function that is disassembled. Until now the whole file was included which wasted a lot of performance since KSyntaxHighlighter was run on the whole file.