Giter Site home page Giter Site logo

Comments (3)

vhallac avatar vhallac commented on June 11, 2024

The problem is caused by a bug in the function lua-cleanup-indentation-info. When fed the list

( (remove-matching . 0)
  (replace-matching relative . 4)
  (relative . 4)
  (relative . 0))

it should return (relative . 0) (the second element's cdr should replace the third, and the first one should remove it), but it returns (relative . 4). The problem is, the second case in the function should check erase count as well instead of unconditionally adding the cdr to value.

A quick and dirty fix for the bug is:

(defun lua-cleanup-indentation-info (info)
  "Cleanup the list of indentation information.
There are two tokens that cause list cleanup: remove-matching,
and replace matching. These tokens are considered cleanup tokens.

When a remove-matching token is found, the next non cleanup token
is removed from list.

When a replace-matching token is found, the next non-cleanup
token is removed from the list, and the cdr of the
replace-matching token is inserted in its place."
  (let (value
        (erase-count 0))
    (dolist (elt info value)
      (cond
       ( (eq 'remove-matching (car elt))
         (setq erase-count (1+ erase-count)))
       ( (eq 'replace-matching (car elt))
         (if (= erase-count 0)
             (setq value (cons (cdr elt) value))
           (setq erase-count (1- erase-count)))
         (setq erase-count (1+ erase-count)))
       ( t
         (if (= erase-count 0)
             (setq value (cons elt value))
           (setq erase-count (1- erase-count))))))
    (reverse value)))

A bit of refactoring/simplification would be a good idea. :)

I will try to get a tidied up fix with a pull request for this as soon as I can.

from lua-mode.

immerrr avatar immerrr commented on June 11, 2024

I guess, that's fixed now thanks to Vedat.

from lua-mode.

rrthomas avatar rrthomas commented on June 11, 2024

Indeed; thanks, both of you!

from lua-mode.

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.