- fix: Goto definition/Goto declaration/Info tips can't be correctly triggered when mouse pointer is at the last half character of current word.

This commit is contained in:
Roy Qu 2023-06-15 16:40:47 +08:00
parent dfed4accf6
commit 5e78c0aa62
3 changed files with 17 additions and 21 deletions

View File

@ -4,6 +4,7 @@ Red Panda C++ Version 2.23
- enhancement: Code completion for '->' operator on std iterators.
- enhancement: Tooltip support for '->' operator on std iterators.
- enhancement: Close other editors.
- fix: Goto definition/Goto declaration/Info tips can't be correctly triggered when mouse pointer is at the last half character of current word.
Red Panda C++ Version 2.22

View File

@ -3954,6 +3954,7 @@ Editor::TipType Editor::getTipType(QPoint point, QSynedit::BufferCoord& pos)
{
// Only allow in the text area...
if (pointToCharLine(point, pos) && syntaxer()) {
//qDebug()<<gutterWidth()<<charWidth()<<point.y()<<point.x()<<pos.line<<pos.ch;
if (!pMainWindow->debugger()->executing()
&& getSyntaxIssueAtPosition(pos)) {
return TipType::Error;

View File

@ -644,28 +644,22 @@ bool QSynEdit::pointToCharLine(const QPoint &point, BufferCoord &coord)
{
// Make sure it fits within the SynEdit bounds (and on the gutter)
if ((point.x() < gutterWidth() + clientLeft())
|| (point.x()>clientWidth()+clientLeft())
|| (point.x()> clientWidth()+clientLeft())
|| (point.y() < clientTop())
|| (point.y() > clientTop()+clientHeight())) {
return false;
}
coord = displayToBufferPos(pixelsToNearestRowColumn(point.x(),point.y()));
coord = displayToBufferPos(pixelsToRowColumn(point.x(),point.y()));
return true;
}
bool QSynEdit::pointToLine(const QPoint &point, int &line)
{
// Make sure it fits within the SynEdit bounds
if ((point.x() < clientLeft())
|| (point.x()>clientWidth()+clientLeft())
|| (point.y() < clientTop())
|| (point.y() > clientTop()+clientHeight())) {
return false;
}
BufferCoord coord = displayToBufferPos(pixelsToNearestRowColumn(point.x(),point.y()));
line = coord.line;
BufferCoord coord;
bool result = pointToCharLine(point,coord);
if (result)
line=coord.line;
return true;
}
@ -1225,23 +1219,23 @@ void QSynEdit::unCollpaseAll()
void QSynEdit::processGutterClick(QMouseEvent *event)
{
int X = event->pos().x();
int Y = event->pos().y();
DisplayCoord RowColumn = pixelsToNearestRowColumn(X, Y);
int Line = rowToLine(RowColumn.Row);
int x = event->pos().x();
int y = event->pos().y();
DisplayCoord rowColumn = pixelsToNearestRowColumn(x, y);
int line = rowToLine(rowColumn.Row);
// Check if we clicked on a folding thing
if (mUseCodeFolding) {
PCodeFoldingRange foldRange = foldStartAtLine(Line);
PCodeFoldingRange foldRange = foldStartAtLine(line);
if (foldRange) {
// See if we actually clicked on the rectangle...
//rect.Left := Gutter.RealGutterWidth(CharWidth) - Gutter.RightOffset;
QRect rect;
rect.setLeft(mGutterWidth - mGutter.rightOffset());
rect.setRight(rect.left() + mGutter.rightOffset() - 4);
rect.setTop((RowColumn.Row - mTopLine) * mTextHeight);
rect.setTop((rowColumn.Row - mTopLine) * mTextHeight);
rect.setBottom(rect.top() + mTextHeight - 1);
if (rect.contains(QPoint(X, Y))) {
if (rect.contains(event->pos())) {
if (foldRange->collapsed)
uncollapse(foldRange);
else
@ -1252,8 +1246,8 @@ void QSynEdit::processGutterClick(QMouseEvent *event)
}
// If not, check gutter marks
if (Line>=1 && Line <= mDocument->count()) {
emit gutterClicked(event->button(),X,Y,Line);
if (line>=1 && line <= mDocument->count()) {
emit gutterClicked(event->button(),x,y,line);
}
}