-
-
Notifications
You must be signed in to change notification settings - Fork 654
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
V2 of refactor LiveText to use diff-match-patch #11639
Conversation
Cc @camlorn, @feerrenrut, @LeonarddeR, @michaelDCurran, @tspivey. |
Thanks for the update @codeofdusk. I don't think it is a good idea to try to rush this, it would be nice to get it into 2020.4, but we have to be realistic about the amount of work left to do. If it is ready in time we will include it.
|
This comment has been minimized.
This comment has been minimized.
Is this winapi module you used also part of the c++ code? |
This comment has been minimized.
This comment has been minimized.
The open questions are in the current diff for this PR, in particular synchronization for their creation. The link was showing you how to use standard input from python.
The benefits of doing this (that I can immediately identify):
I think there is likely to be minimal overhead for this. Most of the work will be done by the native parts of python anyway.
If you still wish me to review that code then I'll set some time aside to write things up properly, in the meantime you could look at some modern C++ examples specifically on memory management. |
This comment has been minimized.
This comment has been minimized.
Perhaps, eventually. Please start by getting this delivered using standard IO.
This is not necessary, it's a very simple program, but it is not following modern approaches, this makes it error prone. Judging by the minimalism of the code, I suspect it doesn't handle failures well. To learn more, the following is a good resource: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines Please try to write this in python instead. |
This comment has been minimized.
This comment has been minimized.
Just to be clear, this is using JoshData/diff_match_patch-python right?
What happens? How do these fail? There are some other suggestions on how to do this on stackoverflow, but it would be good to understand why this fails.
Yes, we'll have to add a way to run an external script to NVDA. Eventually it should be a separate executable, but for now you could add an option to NVDA to execute a script with Finally, an alternative would be to create a python extension using the LGPL-2.1 licensed opencor/libxdiff or similar libraries (eg xdiff from libgit). This still uses the same Meyers diff algorithm used by diff match patch. The advantage is it could be run in the same process. |
Can't we just compile the Python script to exe similar to how
I guess it would be simpler to add such option to nvda_slave. |
This comment has been minimized.
This comment has been minimized.
Ok, that is something to deal with. That said the warning Looking at the sample you posted:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
… requires that NVDA be run from source!
See test results for failed build of commit 1e65d27cef |
@feerrenrut I've updated the PR and description. |
This also adds the DMP Python extension to the repo, but I'm unsure if it should be in a different location.
The build is failing, but I can't see why. What's going on here? Cc @feerrenrut, @LeonarddeR, @michaelDCurran. |
In setup.py, you have explicitly imported some things from versionInfo,
no doubt to make linting happy. However, versionInfo is already
specifically imported further down, underneath where gettext is imported
and installed, providing ```_()```.
You need to move your versionInfo import down past the gettext stuff.
Of course flake8 may complain about imports not at the top of the file,
but you'll have to silence that with a flake8 comment.
|
…d to more accurately describe behaviour.
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.
This looks ok. I think it will need significant testing, so I'm not comfortable to include it at this late stage in the 2020.4 release. I'll merge it for release with 2021.1 as soon as we branch off for the beta.
This comment has been minimized.
This comment has been minimized.
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.
Thanks for your work on this @codeofdusk
55a7d69
to
78e4012
Compare
There seems to be a deadlock somewhere in this code, making autoread stop working sometimes in some consoles. I've had a tough time finding it. Hopefully someone will report the issue with a clear set of steps to reproduce. |
It’s very hard give steps to reproduce, as it happens randomly, for example in the wsl consoles.
1. Windows subsistem for linux
|
@codeofdusk see if you can get a stack trace / log for it. That will give a lot of clues about what is going on. |
It looks like the 'in nvda process' code doesn't flush More research is required to determine if it necessary to flush for each "step" in the communication. |
I've found a set of steps to reproduce on my particular system. Adding flush calls at various points in the communication process does not appear to change behaviour in any way. |
#11998 includes a possible patch for the described diff hang issue. |
Link to issue number:
Supersedes #11500. Closes #3200. Closes #11498.
Summary of the issue:
LiveText
objects use difflib to calculate text changes:Description of how this pull request fixes the issue:
This PR changes diffing functions to operate at the string rather than line level and adds diff-match-patch (DMP) as an optional diffing algorithm for
LiveText
objects. It is anticipated that DMP will become the default in a future NVDA release pending positive user testing.Unlike #11500, this PR does not import or dynamically link to DMP due to licensing issues. Instead, a Python application is run in another process that calls the DMP extension, and communicates over standard IO.
Testing performed:
Known issues with pull request:
None.
Change log entry:
== Bug Fixes ==
== Changes For Developers ==
LiveText._getTextLines
has been removed. Instead, override_getText
which returns a string of all text in the object. (V2 of refactor LiveText to use diff-match-patch #11639)LiveText
objects can now calculate diffs by character. To forcibly modify this for a particular object, override thediffAlgo
property (see the docstring for details). (V2 of refactor LiveText to use diff-match-patch #11639)