Skip to content

Open File: wrong determination of the caret position #14543

@slwmr

Description

@slwmr

Description and Steps to Reproduce the Issue

I have a line of text:
(tab)(tab)(tab)tst.txt
three tab characters and the file name (the file is in the same directory as the file I'm editing).

I want to open the file with the context menu and the option 'Open File'.
I can't open the file if I place the caret on the file name, but I can do that if I place the caret between the first and the second tab.

Analysis

I think the problem is in NppBigSwitch.cpp
...
case NPPM_GETFILENAMEATCURSOR:
...
col = _pEditView->getCurrentColumnNumber();
This method uses SCI_GETCOLUMN to determine the caret position in the string.
We have tabs as single characters in the string, but SCI_GETCOLUMN takes into account how many 'spaces' every tab (on the left side of the caret) takes.

SCI_GETCOLUMN(position pos) → position
This message returns the column number of a position pos within the document taking the width of tabs into account. This returns the column number of the last tab on the line before pos, plus the number of characters between the last tab and pos.

Guessing where to click could be fun for short lines, but for long ones with many tab characters... ;)

Debug Information

Notepad++ v8.6 (32-bit)
Build time : Nov 23 2023 - 16:56:22
Path : C:\b\Notepad++\notepad++.exe
Admin mode : OFF
Local Conf mode : ON
Cloud Config : OFF
OS Name : Windows 10 Home (64-bit)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions