-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: parseComponent's pad: true option should use spaces for padding #5058
Comments
Hello, I'm working on a vue extension for VSCode.
This sounds really interesting. Will that take the form of a language server following LSP, or do you plan to write client plugins for all these editors? Also microsoft/TypeScript#14141 doesn't seem to be able to handle vuex. For example, suggesting Would be great if you can open a devoted issue for this plugin and give a bit more detail. I feel sorry for digressing from the original topic, but this is exciting and I look forward to integrate your work. |
Yes, it will use the normal Typescript language service for JS/TS, extended using the new Typescript plugin API. Right now you have to add a I prototyped the plugin using emacs, which does only support the script block. For VS Code I am trying to get vetur's script block support working with the plugin so that existing HTML intellisense will still work and Typescript will be able to provide better intellisense inside the script block. Supporting things like I don't know much about the Vue ecosystem, so I need to go learn about vuex to understand its usage patterns. I'll open a separate issue on vetur's repo and we can discuss both intellisense and vuex usage there. |
When an external tool is using vue-template-compiler to grab the script block,
{ pad: true }
fills in preceding non-script lines with//
so that line+column-oriented tools can get the line numbers right.However, this doesn't work as well for character-oriented tools like the Typescript language service, which treat positions as a single index into a single string. It would be better if
{ pad: true }
replaced the contents of all non-script blocks with spaces.For example:
Current behaviour prints:
Desired behaviour prints:
except instead of
.
.
, it should printMotivation
For background, I'm working on a Vue plugin for the Typescript language service so that editors like VS Code, Visual Studio, Sublime, emacs, etc, can get Javascript and Typescript completions inside .vue files. The next version of Typescript will support full completions on Vue and Vue options objects with no type annotations, and the plugin will make that work inside
.vue
files as well as.js
and.ts
files.I tried using the
start/end
offsets returned fromparseComponent
, which kind of works, but Typescript has previously only used offsets for non-critical parsing like JSDoc. I'd like to use the space-replacing technique since I know it has worked in the past, for example in Visual Studio's handling of Javascript embedded in HTML.Implementation
Replace the body of
padContent
insrc/sfc/parser.js
withreturn content.slice(0, block.start).replace(/./g, ' ')
. This correctly avoids replacing both\n
and\r\n
, at least on node 7.4 on Linux.I'll send a PR as soon as I get Vue building and have added a test.
The text was updated successfully, but these errors were encountered: