diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Document.cxx | 13 | ||||
| -rw-r--r-- | src/Document.h | 2 | 
2 files changed, 10 insertions, 5 deletions
| diff --git a/src/Document.cxx b/src/Document.cxx index e5022ad64..6dc14238f 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -674,7 +674,7 @@ int Document::LenChar(Sci::Position pos) const noexcept {  			return utf8status & UTF8MaskWidth;  		}  	} else { -		if (IsDBCSLeadByteNoExcept(leadByte) && ((pos + 1) < LengthNoExcept())) { +		if (IsDBCSLeadByteNoExcept(leadByte) && IsDBCSTrailByteNoExcept(cb.CharAt(pos + 1))) {  			return 2;  		} else {  			return 1; @@ -709,7 +709,7 @@ bool Document::InGoodUTF8(Sci::Position pos, Sci::Position &start, Sci::Position  	}  } -// Normalise a position so that it is not halfway through a two byte character. +// Normalise a position so that it is not part way through a multi-byte character.  // This can occur in two situations -  // When lines are terminated with \r\n pairs which should be treated as one character.  // When displaying DBCS text such as Japanese. @@ -760,7 +760,7 @@ Sci::Position Document::MovePositionOutsideChar(Sci::Position pos, Sci::Position  			// Check from known start of character.  			while (posCheck < pos) { -				const int mbsize = IsDBCSLeadByteNoExcept(cb.CharAt(posCheck)) ? 2 : 1; +				const int mbsize = IsDBCSDualByteAt(posCheck) ? 2 : 1;  				if (posCheck + mbsize == pos) {  					return pos;  				} else if (posCheck + mbsize > pos) { @@ -825,7 +825,7 @@ Sci::Position Document::NextPosition(Sci::Position pos, int moveDir) const noexc  			}  		} else {  			if (moveDir > 0) { -				const int mbsize = IsDBCSLeadByteNoExcept(cb.CharAt(pos)) ? 2 : 1; +				const int mbsize = IsDBCSDualByteAt(pos) ? 2 : 1;  				pos += mbsize;  				if (pos > cb.Length())  					pos = cb.Length(); @@ -1098,6 +1098,11 @@ int Document::DBCSDrawBytes(std::string_view text) const noexcept {  	}  } +bool Document::IsDBCSDualByteAt(Sci::Position pos) const noexcept { +	return IsDBCSLeadByteNoExcept(cb.CharAt(pos)) +		&& IsDBCSTrailByteNoExcept(cb.CharAt(pos + 1)); +} +  static constexpr bool IsSpaceOrTab(int ch) noexcept {  	return ch == ' ' || ch == '\t';  } diff --git a/src/Document.h b/src/Document.h index c40ce2a44..fe27f4936 100644 --- a/src/Document.h +++ b/src/Document.h @@ -330,8 +330,8 @@ public:  	bool SCI_METHOD IsDBCSLeadByte(char ch) const override;  	bool IsDBCSLeadByteNoExcept(char ch) const noexcept;  	bool IsDBCSTrailByteNoExcept(char ch) const noexcept; -	bool IsDBCSLeadByteInvalid(char ch) const noexcept;  	int DBCSDrawBytes(std::string_view text) const noexcept; +	bool IsDBCSDualByteAt(Sci::Position pos) const noexcept;  	int SafeSegment(const char *text, int length, int lengthSegment) const noexcept;  	EncodingFamily CodePageFamily() const noexcept; | 
