diff --git a/sequencecellrenderer.c b/sequencecellrenderer.c index 1c7c30df3618de64f8f7dd4ff290578ecc4c7e60..81916649c112c445c3236f49d7279a07e515cfb9 100755 --- a/sequencecellrenderer.c +++ b/sequencecellrenderer.c @@ -836,7 +836,7 @@ static IntRange getVisibleMspRange(MSP *msp, RenderData *data) if (rangesOverlap(&result, data->displayRange)) { /* Limit the returned range to the display range. */ - boundsLimitRange(&result, data->displayRange); + boundsLimitRange(&result, data->displayRange, FALSE); } else { diff --git a/utilities.c b/utilities.c index d4acb9154bd4e47217bb88ba48236450b96aef75..20ea9d45bbc88ff66c68af2b7e9d3c0bb2c74ace 100644 --- a/utilities.c +++ b/utilities.c @@ -261,25 +261,33 @@ void boundsLimitValue(int *value, const IntRange const *range) } -/* Utility to bounds-limit the first range to within the second. Maintains the length - * of the range if possible by shifting the range. */ -void boundsLimitRange(IntRange *range, const IntRange const *limit) +/* Utility to bounds-limit the first range to within the second. If maintainLen is true, maintains + * the length of the range if possible by shifting the range. */ +void boundsLimitRange(IntRange *range, const IntRange const *limit, const gboolean maintainLen) { const int len = getRangeLength(range); if (range->min < limit->min) { range->min = limit->min; - range->max = range->min + len; + + if (maintainLen) + { + range->max = range->min + len; + } } if (range->max > limit->max) { range->max = limit->max; - range->min = range->max - len; - /* If limit is shorter than range, we'll have gone lower than the min again */ - boundsLimitValue(&range->min, limit); + if (maintainLen) + { + range->min = range->max - len; + + /* If limit is shorter than range, we'll have gone lower than the min again */ + boundsLimitValue(&range->min, limit); + } } diff --git a/utilities.h b/utilities.h index e8042b9f69f08a49df616dd36c95511595006c6c..3a9ebbad4dd654defce6aec0d1a07f9217443159 100644 --- a/utilities.h +++ b/utilities.h @@ -184,7 +184,7 @@ int getRangeCentre(const IntRange const *range); gboolean valueWithinRange(const int value, const IntRange const *range); gboolean rangesOverlap(const IntRange const *range1, const IntRange const *range2); void boundsLimitValue(int *value, const IntRange const *range); -void boundsLimitRange(IntRange *range, const IntRange const *limit); +void boundsLimitRange(IntRange *range, const IntRange const *limit, const gboolean maintainLen); char convertBaseToCorrectCase(const char charToConvert, const BlxSeqType seqType); int convertDisplayIdxToDnaIdx(const int inputIdx,