Skip to content
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

We need a API - positionAt(byte offset) #5735

Closed
owent opened this issue Apr 25, 2016 · 9 comments
Closed

We need a API - positionAt(byte offset) #5735

owent opened this issue Apr 25, 2016 · 9 comments
Labels
api feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code
Milestone

Comments

@owent
Copy link

owent commented Apr 25, 2016

  • VSCode Version: 1.0.0
  • OS Version: windows 10

I want to make the extension "clang-format" work better with chinese(or other asia languages).But clang-format only provide byte offsets of a text.Using TextDocument.positionAt, we will got a Position object with charactor offset but not byte offset.

Steps to Reproduce:

  1. Run "clang-format -output-replacements-xml -style=llvm" for file https://github.com/atframework/atframe_utils/blob/master/include/string/ac_automation.h, we get the first replacement node with offset='288' and length='180'.
  2. We use TextDocument.positionAt(288), we get line=19 and col=15
  3. But what we want is line=19 and col=1
  4. The problem is "自动机算法实现"(UTF-8) takes 21 bytes, but VSCode think it has 7 charaters.

I think it's better for vscode provide a API to do so, than we analysis all the content again.

@owent
Copy link
Author

owent commented Apr 25, 2016

We also need the API _byteOffsetAt_ which just like TextDocument.offsetAt

owent added a commit to owent-contrib/vscode-clang-format-provider that referenced this issue Apr 25, 2016
@bpasero bpasero changed the title feature request: We need a API - positionAt(byte offset) We need a API - positionAt(byte offset) Apr 25, 2016
@bpasero bpasero added the api label Apr 25, 2016
@jrieken
Copy link
Member

jrieken commented Apr 25, 2016

fyi @alexandrudima

@jrieken
Copy link
Member

jrieken commented Apr 26, 2016

@owt5008137 clang-format seems to have a line-based mode. http://clang.llvm.org/docs/ClangFormat.html

any special reasons you don't use 'lines' for what you want to achieve?

@owent
Copy link
Author

owent commented Apr 27, 2016

@jrieken We allow users only format the selected codes, and any user can select any code section, with or without the whole line.

@jrieken
Copy link
Member

jrieken commented Apr 27, 2016

Understood, still you should consider using that since add support for bytes won't come soon as this is a huge effort across our whole stack

@owent
Copy link
Author

owent commented Apr 27, 2016

@jrieken Thanks.I use Buffer class to decode the text and calculate the byte-offset now.I will replace the codes and use the decode result of VSCode after these APIs are provided.

@jrieken
Copy link
Member

jrieken commented Nov 17, 2017

This feature request will not be considered in the next 6-12 months roadmap and as such will be closed to keep the number of issues we have to maintain actionable. Thanks for understanding and happy coding!

@nhooyr
Copy link

nhooyr commented Aug 31, 2018

Does the reopening of this mean it will be considered?

At coder, we need this feature for our collaborative editing to work performantly. Could you provide a outline on exactly what needs to be done where and we might be able to get a PR in for it.

@jrieken jrieken assigned rebornix and unassigned jrieken Oct 4, 2019
@rebornix rebornix removed their assignment Oct 24, 2019
@rebornix rebornix added this to the Backlog milestone Oct 24, 2019
@alexdima alexdima added the *out-of-scope Posted issue is not in scope of VS Code label Oct 25, 2019
@vscodebot
Copy link

vscodebot bot commented Oct 25, 2019

We closed this issue because we don't plan to address it in the foreseeable future. You can find more detailed information about our decision-making process here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding and happy coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code
Projects
None yet
Development

No branches or pull requests

6 participants