tfry added a comment.

  Regarding the unit tests: Take a look at e.g. 
https://cgit.kde.org/ktexteditor.git/tree/autotests/input/indent/cmake/enter1 . 
You start with an initial text "origin", then emulate some input "input.js", an 
specify the expected state at the end "expected".
  
  Again, I have no experience with indentation scripts, so no good idea what 
they should look like. A nitpick / idea is inlined.

INLINE COMMENTS

> r.js:174
> +// Returns -1 if nothing was found
> +function findAlignOperator(lineNr, pos) {
> +    var lineString = document.line(lineNr);

I wonder if this cannot be simplified (but not sure I understand the complete 
logic). Pseudo-code:

  var brackets = new Array();
  for ([iterating backwards, skipping strings and comments]) {
     var current_char = [...];
     var closing_type = closings.indexOf(current_char);
     if (closing_type >= 0) {
       brackets.push(current_char);
     } else {
       var opening_type = openings.indexOf(current_char);
       if (opening_type >= 0 && brackets.pop() != current_char) {
          [mismatch: return]
       }
       [...]
     }
  }

REPOSITORY
  R39 KTextEditor

REVISION DETAIL
  https://phabricator.kde.org/D12587

To: devillemereuil, #ktexteditor, #rkward
Cc: tfry, dhaumann, #frameworks, michaelh, kevinapavew, ngraham, bruns, 
demsking, cullmann, sars

Reply via email to