Giter Club home page Giter Club logo

Comments (5)

notnarb avatar notnarb commented on July 17, 2024 1

Thank you for the extremely fast turnaround!
As of 20170530.953, this issue appears to be fixed for me.

And thank you for the in-depth explanation! One day I hope to better be able to contribute to elisp projects so I find this stuff very interesting

from typescript.el.

josteink avatar josteink commented on July 17, 2024

Thanks for the very detailed bug-report! I can reproduce this one.

From what I can tell indent-according-to-mode calls back into typescript-indent-line (which was fixed for another error 26.05.2017) and this seems to introduce the error.

In your example our new "unicode-aware" typescript--current-column function returns 23 where regular current-column returns 30 (which is also reported by column-number-mode) This causes the cursor to be positioned incorrectly. This is obviously wrong.

Looking at it in depth, it seems this was caused by the first char of the line actually being a tab, which column-wise would represent 8 spaces. (Thus 23-1+8 = 30)

A temporary workaround could be not to use tabs, but prefer spaces, but I can see how that doesn't work out for everyone.

I'm not sure what a good solution for everyone would be here, but I'll try to take a deeper look at it.

from typescript.el.

josteink avatar josteink commented on July 17, 2024

Update: basically it seems like the column and char concept in Emacs is not really compatible, and should not ever be mixed when doing accounting:

  • a single Chinese/Wide unicode character counts as several "columns", but as 1 character.
  • a tab counts as 1 character, but also as several "columns".

As long as typescript-indent-line mixes these, we will get errors, and I think the best approach is to rewrite it to use columns exclusively.

This means we'll have to replace forward-char with move-to-column for repositioning.

from typescript.el.

josteink avatar josteink commented on July 17, 2024

Added another test-case. With this patch in, indentation works for both tabs and wide chars.

Let me know if it works for you as well.

from typescript.el.

josteink avatar josteink commented on July 17, 2024

Thanks for reporting back! Glad to hear your issues are solved.

As for detailed explanation... Consider it thinking out loudly. Sometimes I can't figure out how to fix things, but I have made concrete findings. By reporting these it may help other Emacs'ers spot the error instead. ;)

from typescript.el.

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.