I’m currently working on adding some new features to the D bundle. These are features like code completion, go-to-definition and similar features. These commands are using a parser tool which expects the current cursor position in bytes from the start of the source file. TextMate only provides the cursor position in the form of column and line number. This requires the commands to convert to and from cursor position in bytes to cursor position in column/line number. Is this information something that TextMate already has and can provide or, if not, provide it in a more efficient way then the conversion performed by the command?
I would also need to be able to specify the cursor position in bytes using the “mate” tool. I’ve also looked at the implementation of the Go bundle for the same commands and it has the same issue.
— /Jacob Carlborg
On 6 Aug 2016, at 21:01, Jacob Carlborg wrote:
[…] This requires the commands to convert to and from cursor position in bytes to cursor position in column/line number. Is this information something that TextMate already has and can provide or, if not, provide it in a more efficient way then the conversion performed by the command?
I would also need to be able to specify the cursor position in bytes using the “mate” tool. I’ve also looked at the implementation of the Go bundle for the same commands and it has the same issue.
If you ask TextMate to jump to offset 1,000 then I assume you expect this to be based on the bytes on disk, but TextMate may convert encoding or line delimiters when loading a file, so it would need to map the offset to match the memory representation.
IMHO the tool should be updated to output warnings/errors as line:column and not byte offset.
On 07 Aug 2016, at 16:20, Allan Odgaard mailinglist@textmate.org wrote:
If you ask TextMate to jump to offset 1,000 then I assume you expect this to be based on the bytes on disk, but TextMate may convert encoding or line delimiters when loading a file, so it would need to map the offset to match the memory representation.
Right. Is TextMate using the same encoding as the file or an internal encoding. Or is that an implementation detail?
IMHO the tool should be updated to output warnings/errors as line:column and not byte offset.
I can file an enhancement request for the tool and see what they say.
— /Jacob Carlborg
On 7 Aug 2016, at 21:09, Jacob Carlborg wrote:
[…] Is TextMate using the same encoding as the file or an internal encoding. Or is that an implementation detail?
Currently it uses UTF-8 internally but I would say it’s an implementation detail (1.x used UTF-16 for better compatibility with NSString and friends).
IMHO the tool should be updated to output warnings/errors as line:column and not byte offset.
I can file an enhancement request for the tool and see what they say.
If they won’t support this, we could add support to `mate` but I would prefer to keep it as an extension of the current `-l/--line` syntax, e.g. `--line +42` to indicate a byte offset of 42.
On 6 Aug 2016, at 21:01, Jacob Carlborg wrote:
I’m currently working on adding some new features to the D bundle. These are features like code completion, go-to-definition and similar features. These commands are using a parser tool which expects the current cursor position in bytes from the start of the source file. TextMate only provides the cursor position in the form of column and line number.
We can provide this as a variable but the user can have multiple insertion points, column selections, and place carets beyond end-of-line or a tab character.
Any suggestion as for how to provide this info?
On 09 Aug 2016, at 20:59, Allan Odgaard mailinglist@textmate.org wrote:
We can provide this as a variable but the user can have multiple insertion points, column selections, and place carets beyond end-of-line or a tab character.
Any suggestion as for how to provide this info?
I was thinking a new environment variable. Is it any different than TM_LINE_NUMBER?
-- /Jacob Carlborg
On 10 Aug 2016, at 8:45, Jacob Carlborg wrote:
On 09 Aug 2016, at 20:59, Allan Odgaard mailinglist@textmate.org
wrote:
We can provide this as a variable but the user can have multiple insertion points, column selections, and place carets beyond end-of-line or a tab character.
Any suggestion as for how to provide this info?
I was thinking a new environment variable. Is it any different than TM_LINE_NUMBER?
The “line number” does not need to care about most of what I mentioned above, ideally it would reflect when there are carets on multiple lines, but as the variable was introduced before this was a feature, we cannot extend the format without breaking existing stuff and instead a new variable was introduced with exact information (`TM_SELECTION`).
The format of `TM_SELECTION` is:
selection = <range> ('&' <range>)* range = <pos> | <normal_range> | <column_range> pos = <line> (':' <column>)? ('+' <offset>)? normal_range = <pos> '-' <pos> column_range = <pos> 'x' <pos> line = [1-9][0-9]* column = [1-9][0-9]* offset = [1-9][0-9]*
On 10 Aug 2016, at 09:47, Allan Odgaard mailinglist@textmate.org wrote: The “line number” does not need to care about most of what I mentioned above, ideally it would reflect when there are carets on multiple lines, but as the variable was introduced before this was a feature, we cannot extend the format without breaking existing stuff and instead a new variable was introduced with exact information (TM_SELECTION).
The format of TM_SELECTION is:
selection = <range> ('&' <range>)* range = <pos> | <normal_range> | <column_range> pos = <line> (':' <column>)? ('+' <offset>)? normal_range = <pos> '-' <pos> column_range = <pos> 'x' <pos> line = [1-9][0-9]* column = [1-9][0-9]* offset = [1-9][0-9]*
Sorry, I was actually thinking of the TM_LINE_INDEX environment variable. But perhaps the answer is the same anyway.
-- /Jacob Carlborg