Giter VIP home page Giter VIP logo

Comments (10)

Hackerpilot avatar Hackerpilot commented on August 23, 2024

What are the units on the column number? Are they code points or code units?

from dcd.

Dav1dde avatar Dav1dde commented on August 23, 2024

According to the Kdevelop guys it's measured in 16bit characters (UTF-16), so calling toUTF16 on the line and looking up the "column" character should work.

from dcd.

Hackerpilot avatar Hackerpilot commented on August 23, 2024

UTF-16 code points can take up 32 bytes. You meant code units, right?

from dcd.

Dav1dde avatar Dav1dde commented on August 23, 2024

From what I found out it uses QString which is supposed to handle unicode correctly, also from my testings it looked like it would tell the position in code points, rather than code units.

from dcd.

Hackerpilot avatar Hackerpilot commented on August 23, 2024

The lexer used by DCD only operates on UTF-8 text and then only stores byte offsets in its tokens. I used an optimization that relies on the fact that all keywords, operators and quote characters in D fit into a single byte. The lexer avoids using char[] as much as possible, and instead types everything as byte[] to avoid accidentally triggering any Phobos functions that perform decoding. If I wanted to store column numbers in code units the lexer would be much, much slower.

I think that it would make more sense to calculate a byte column number inside of your editor plugin before passing this column number to DCD.

from dcd.

Hackerpilot avatar Hackerpilot commented on August 23, 2024

The token structure is defined and documented here: https://github.com/Hackerpilot/Dscanner/blob/master/stdx/d/lexer.d#L129

from dcd.

Dav1dde avatar Dav1dde commented on August 23, 2024

I see, I thought it was some kind of combination of "dscanner" and the server, but this way it makes more sense. So I have to calculate the "byte length" for every line and sum it up, let's see if I can come up with something.

Can I pass the line and column (in a byte offset) to the server? The struct looks like it could work, that would simplify that a bit and definitly be more efficient.

from dcd.

Hackerpilot avatar Hackerpilot commented on August 23, 2024

Adding a column and line option to the client with corresponding changes to the message struct and the server would be fairly easy.

The server does cursor to token translation here. You should be able to enhance it to pass a function that compares the line and column numbers to lowerBound.

from dcd.

Dav1dde avatar Dav1dde commented on August 23, 2024

Can't you add support for Line:Column support in the Client? This would require the client to actually read the file, but I think that is not too bad.

from dcd.

Hackerpilot avatar Hackerpilot commented on August 23, 2024

Given that
a) Many editor plugins have been implemented without this feature
b) it would add complexity to the client and server code
I'm going to close this.

from dcd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.