- 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: Code completion for '->' operator on std iterators.
- enhancement: Tooltip support for '->' operator on std iterators. - enhancement: Tooltip support for '->' operator on std iterators.
- enhancement: Close other editors. - 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 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... // Only allow in the text area...
if (pointToCharLine(point, pos) && syntaxer()) { if (pointToCharLine(point, pos) && syntaxer()) {
//qDebug()<<gutterWidth()<<charWidth()<<point.y()<<point.x()<<pos.line<<pos.ch;
if (!pMainWindow->debugger()->executing() if (!pMainWindow->debugger()->executing()
&& getSyntaxIssueAtPosition(pos)) { && getSyntaxIssueAtPosition(pos)) {
return TipType::Error; return TipType::Error;

View File

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