Skip to content

Commit

Permalink
Use Diff Match Patch by default when available (#12485)
Browse files Browse the repository at this point in the history
Diff Match Patch (DMP) was included but disabled by default in 2021.1. It fixes #3200 and allows for drastically fewer cross-process calls in UIA console, improving performance in busy applications.

This PR enables DMP by default to allow for wider user testing in master snapshots. If user feedback is positive, use by default in 2021.2.
  • Loading branch information
codeofdusk authored Jun 2, 2021
1 parent 091b315 commit c9bb993
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
11 changes: 5 additions & 6 deletions source/diffHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,13 @@ def _getText(self, ti: TextInfo) -> str:
def get_dmp_algo():
"""
This function returns a Diff Match Patch object if allowed by the user.
DMP is experimental and can be explicitly enabled/disabled by a user
setting to opt in or out of the experiment. If config does not allow
DMP, this function returns a Difflib instance instead.
DMP is new and can be explicitly disabled by a user setting. If config
does not allow DMP, this function returns a Difflib instance instead.
"""
return (
_dmp
if config.conf["terminals"]["diffAlgo"] == "dmp"
else _difflib
_difflib
if config.conf["terminals"]["diffAlgo"] == "difflib"
else _dmp
)


Expand Down
2 changes: 1 addition & 1 deletion source/gui/settingsDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2681,7 +2681,7 @@ def __init__(self, parent):
# Translators: A choice in a combo box in the advanced settings
# panel to have NVDA determine the method of detecting changed
# content in terminals automatically.
_("Automatic (Difflib)"),
_("Automatic (Diff Match Patch)"),
# Translators: A choice in a combo box in the advanced settings
# panel to have NVDA detect changes in terminals
# by character when supported, using the diff match patch algorithm.
Expand Down
3 changes: 3 additions & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ What's New in NVDA

== Bug Fixes ==
- In Windows 10 Calculator, NVDA will announce calculator expressions on a braille display. (#12268)
- In terminal programs on Windows 10 version 1607 and later, when inserting or deleting characters in the middle of a line, the characters to the right of the caret are no longer read out. (#3200)
- Diff Match Patch now enabled by default. (#12485)
-
-


Expand Down
5 changes: 2 additions & 3 deletions user_docs/en/userGuide.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -1875,11 +1875,10 @@ In untrusted environments, you may temporarily disable [speak typed characters #
==== Diff algorithm ====[DiffAlgo]
This setting controls how NVDA determines the new text to speak in terminals.
The diff algorithm combo box has three options:
- Automatic: as of NVDA 2021.1, this option is equivalent to Difflib.
In a future release, it may be changed to Diff Match Patch pending positive user testing.
- Automatic: as of NVDA 2021.2, this option is equivalent to "allow Diff Match Patch".
- allow Diff Match Patch: This option causes NVDA to calculate changes to terminal text by character.
It may improve performance when large volumes of text are written to the console and allow more accurate reporting of changes made in the middle of lines.
However, it may be incompatible with some applications.
However, it may be incompatible with some applications, so Diff Match Patch is not always used.
This feature is supported in Windows Console on Windows 10 versions 1607 and later.
Additionally, it may be available in other terminals on earlier Windows releases.
- force Difflib: this option causes NVDA to calculate changes to terminal text by line.
Expand Down

0 comments on commit c9bb993

Please sign in to comment.