Skip to content
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

Beta to master #16517

Merged
merged 12 commits into from
May 10, 2024
6 changes: 5 additions & 1 deletion source/NVDAObjects/window/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,11 @@ def __init__(self,obj,position,_rangeObj=None):
self._rangeObj=self.obj.ITextSelectionObject.duplicate
elif position==textInfos.POSITION_CARET:
self._rangeObj=self.obj.ITextSelectionObject.duplicate
self._rangeObj.Collapse(True)
startActive: bool = (self.obj.ITextSelectionObject.Flags & comInterfaces.tom.tomSelStartActive) > 0
# Notice: in the following line Collapse() method is called on ITextRange object, not on TextInfo.
# It's boolean argument has the opposite meaning from the one in TextInfo:
# True means collapse to the start, while False means collapse to the end
self._rangeObj.Collapse(startActive)
elif position==textInfos.POSITION_FIRST:
self._rangeObj=self.obj.ITextDocumentObject.range(0,0)
elif position==textInfos.POSITION_LAST:
Expand Down
6 changes: 4 additions & 2 deletions source/addonStore/dataManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import requests
from requests.structures import CaseInsensitiveDict
from json import JSONDecodeError

import addonAPIVersion
from baseObject import AutoPropertyObject
Expand Down Expand Up @@ -183,16 +184,17 @@ def _getCachedAddonData(self, cacheFilePath: str) -> Optional[CachedAddonsModel]
return None
try:
data = cacheData["data"]
cachedAddonData = _createStoreCollectionFromJson(data)
cacheHash = cacheData["cacheHash"]
cachedLanguage = cacheData["cachedLanguage"]
nvdaAPIVersion = cacheData["nvdaAPIVersion"]
except KeyError:
except (KeyError, JSONDecodeError):
log.exception(f"Invalid add-on store cache:\n{cacheData}")
if NVDAState.shouldWriteToDisk():
os.remove(cacheFilePath)
return None
return CachedAddonsModel(
cachedAddonData=_createStoreCollectionFromJson(data),
cachedAddonData=cachedAddonData,
cacheHash=cacheHash,
cachedLanguage=cachedLanguage,
nvdaAPIVersion=tuple(nvdaAPIVersion), # loads as list,
Expand Down
14 changes: 3 additions & 11 deletions source/browseMode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2392,6 +2392,8 @@ def _iterTextStyle(
# if direction == "previous" then it spans from the beginning of current paragraph until cursor+1
# For all following iterations paragraph will represent a complete paragraph.
styles = self._mergeIdenticalStyles(self._extractStyles(paragraph))
if len(styles) < 2:
return
initialStyle = styles[0 if direction == documentBase._Movement.NEXT else -2]
# Creating currentTextInfo - text written in initialStyle in this paragraph.
currentTextInfo = initialTextInfo.copy()
Expand Down Expand Up @@ -2545,17 +2547,7 @@ def _iterSimilarParagraph(
desiredValue = paragraphFunction(info)
for i in range(self.MAX_ITERATIONS_FOR_SIMILAR_PARAGRAPH):
# move by one paragraph in the desired direction
try:
info.collapse(end=direction == _Movement.NEXT)
except RuntimeError:
# Microsoft Word raises RuntimeError when collapsing textInfo to the last character of the document.
return

if direction == _Movement.PREVIOUS:
if info.move(textInfos.UNIT_CHARACTER, -1) == 0:
return
info.expand(textInfos.UNIT_PARAGRAPH)
if info.isCollapsed:
if not self._moveToNextParagraph(info, direction):
return
value = paragraphFunction(info)
if value == desiredValue:
Expand Down
Loading