Coder Social home page Coder Social logo

Comments (2)

SirZenith avatar SirZenith commented on July 19, 2024

VSCode's approach of handling URI is to unescape everything that is escaped, and colon after drive name is escaped by default, see issue 75027 and issue 144698 of vscode.

As a reference, lua-language-server by sumneko escape most of the characters when generating URI on server side, see here. The escape pattern used [^%w%-%.%_%~%/] means everything that is no letter, number, -, ., _, ~, /.

I think VLS can use similar method. Escape most thing in file path. providing an normalized form of URI for language server to reference files.

I have finished URI encoding and decoding part on my fork.

from vls.

SirZenith avatar SirZenith commented on July 19, 2024

And I propose VLS should use URI in normalized form for storing/fetching file information on server side.

Which is to first decode URI from client, and get file path from it no matter what the URI is. Then encode that file path with encoding function on VLS side. Referencing the target file with this URI made by VLS will make things more consistant.

And that requires adding method like

fn (du DocumentUri) normalize() DocumentUri {
    return document_uri_from_path(du.path())
}

and call it every time we need file information access on VLS side.

pub fn (mut ls Vls) did_open(params lsp.DidOpenTextDocumentParams, mut wr ResponseWriter) {
     uri := params.text_document.uri.normalize()
    // ...
   tree := ls.files[uri].tree
}

And this means everywhere in code that has a ls.files[uri] need to be fixed. That's a lots of work.

from vls.

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.