universal-ctags/issues-we-will-not-fix-in-soon

Add a way to write the position/column to tags file

Opened this issue · 5 comments

I heard there was a way to get Vim to jump to the position of the tag, instead of the start of the line.

Say I have the following code (with the cursor at |):

function myFunction() {
}

|myFunction()

When I press C-] my cursor jumps to:

|function myFunction() {

Supposedly Vim supports placing the cursor in the position shown below, if the tags file contains the right data (for example the column number to place the cursor). I can't exactly find where this is documented though

function |myFunction() {

Adding column is hard.
There is not centric mechanism to record the columns of tags.

We have to work on each parsers.
See my comment in universal-ctags/ctags#1502 .

b4n commented

@masatake many parsers use a filePosition (MIOPos, which is either a byte offset or a fpos_t), and in most cases they pass on the position manually anyway so it shouldn't even be too hard to change 'em all if needed.

However, column is quite tricky in the 21st century: is it a byte offset? is it a character offset? is it a code point offset? Sometimes when people say "column", they even consider the display width of a tab (which isn't meaningful here, but still), etc.
The easier for us is definitely byte offset (as we currently don't handle encoding reading the input), and it might be the easiest for everybody -- but it gotta be clearly agreed upon.
However, if we ever start converting the input so that e.g. parsers can be fed UTF-8 when reading UTF-16, we'd have to carefully keep track of the offset from the actual source. The same problem arises with consumers; if they convert the files upon loading, they'd have to carefully match what offset it meant in the source.

In any case and FWIW, I like the idea of having a more precise location than merely the line.

@b4n, you are correct. Anyway, we have to work on each parser to make it use the filePosition.
@dylan-chong, which languages/parsers are you interested in ? JavaScript?
I will add "column:" field represented in a byteoffset for the parser as a trial.

@b4n, filePosition points the position of the START of the line where the tag is defined.