Menu

#1524 [Patch] Add SCI_LINETAB and SCI_LINEBACKTAB

Committed
open
nobody
scintilla (293)
5
2025-02-26
2024-06-20
No

Here's patch which adds SCI_LINETAB and SCI_LINEBACKTAB. These force the multiline behaviour of SCI_TAB and SCI_BACKTAB and can be used to assign Ctrl+] and Ctrl+[ to indent and unindent/dedent lines like VSCode, even if there's not multiple lines selected. There's no real new code introduced.

The patch also tries to make SCI_BACKTAB's description in Scintilla.iface more accurate. The existing description makes it sounds like SCI_BACKTAB has no special behaviour if there's not multiple lines selected but it actually has.

https://patch-diff.githubusercontent.com/raw/jrsoftware/scintilla/pull/8.diff
https://patch-diff.githubusercontent.com/raw/jrsoftware/scintilla/pull/8.patch
https://github.com/jrsoftware/scintilla/pull/8/files

Discussion

  • Neil Hodgson

    Neil Hodgson - 2024-07-12

    These may be better named to match their result like "indent" and "dedent" instead of the associated key.

     
    • Martijn Laan

      Martijn Laan - 2024-07-26

      I've updated the patch to use the suggested names.

       
  • Neil Hodgson

    Neil Hodgson - 2024-07-31

    Committed as [e91d19] spelt SCI_LINEINDENT and SCI_LINEDEDENT. Message numbers changed.

     

    Related

    Commit: [e91d19]

    • Martijn Laan

      Martijn Laan - 2024-08-03

      Thanks! Also thanks for releasing 5.5.1.

       
    • Martijn Laan

      Martijn Laan - 2024-11-06

      I beleive my original patch has a small mistake making it so that doing SCI_LINEINDENT with the caret and anchor at the start of the same line does nothing.

      I think the fix might be to put a if (!lineIndent) check before this bit in Editor.cxx:

      if (pdoc->LineStart(lineBottomSel) == sel.Range(r).anchor.Position() || pdoc->LineStart(lineBottomSel) == caretPosition)
              lineBottomSel--;    // If not selecting any characters on a line, do not indent
      

      Sorry for the inconvenience.

      Another potential issue is that in the same case doing the indent doesnt cause the line to be selected. Not sure if it should do this or not.

      The reason the line isn't selected is that lineOfAnchor equals lineCurrentPos and anchorPosOnLine = 0 so it does this code which doesn't select anything:

      sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos),
          pdoc->LineStart(lineOfAnchor));
      
       
      • Neil Hodgson

        Neil Hodgson - 2024-11-07

        I think the fix might be to put a if (!lineIndent) check before this bit in Editor.cxx

        This made performing SCI_LINEINDENT twice after the line start cause the next line to move. Perhaps I applied the change wrong as it was described rather than shown as a patch.

         
  • Neil Hodgson

    Neil Hodgson - 2024-07-31
    • Group: Initial --> Committed
     
  • Neil Hodgson

    Neil Hodgson - 2024-08-21
    • status: open --> closed
     
  • Zufu Liu

    Zufu Liu - 2024-08-21

    void Indent(bool forwards, bool lineTab); does not match void Editor::Indent(bool forwards, bool lineIndent) will cause a clang-tidy readability-inconsistent-declaration-parameter-name warning.

    D:\notepad4\scintilla\src\Editor.cxx:1468:2: warning: variable 'll' of type 'std::shared_ptr<LineLayout>' can be declared 'const' [misc-const-correctness]
     1468 |         std::shared_ptr<LineLayout> ll = view.RetrieveLineLayout(lineToWrap, *this);
          |         ^
          |                                     const 
    
    D:\notepad4\scintilla\src\Editor.cxx:1527:4: warning: variable 'llTemporary' of type 'std::shared_ptr<LineLayout>' can be declared 'const' [misc-const-correctness]
     1527 |                         std::shared_ptr<LineLayout> llTemporary = std::make_shared<LineLayout>(-1, 200);
          |                         ^
          |                                                     const 
    D:\notepad4\scintilla\src\Editor.cxx:1534:29: warning: implicit capture of 'this' with a capture default of '=' is deprecated [clang-diagnostic-deprecated-this-capture]
     1534 |                                 const Range rangeLine = pdoc->LineRange(lineNumber);
          |                                                         ^
    D:\notepad4\scintilla\src\Editor.cxx:1525:5: note: add an explicit capture of 'this' to capture '*this' by reference
     1525 |                         [=, &surface, &nextIndex, &linesAfterWrap, &mutexRetrieve]() {
          |                          ^
          |                           , this
    D:\notepad4\scintilla\src\Editor.cxx:1539:7: warning: variable 'guard' of type 'std::lock_guard<std::mutex>' can be declared 'const' [misc-const-correctness]
     1539 |                                                 std::lock_guard<std::mutex> guard(mutexRetrieve);
          |                                                 ^
          |                                                                             const 
    D:\notepad4\scintilla\src\Editor.cxx:1564:2: warning: variable 'llLarge' of type 'std::shared_ptr<LineLayout>' can be declared 'const' [misc-const-correctness]
     1564 |         std::shared_ptr<LineLayout> llLarge = std::make_shared<LineLayout>(-1, 200);
          |         ^
          |                                     const 
    
    D:\notepad4\scintilla\src\Editor.cxx:1737:4: warning: variable 'll' of type 'std::shared_ptr<LineLayout>' can be declared 'const' [misc-const-correctness]
     1737 |                         std::shared_ptr<LineLayout> ll = view.RetrieveLineLayout(line, *this);
          |                         ^
          |                                                     const 
    D:\notepad4\scintilla\src\Editor.cxx:5434:5: warning: variable 'll' of type 'std::shared_ptr<LineLayout>' can be declared 'const' [misc-const-correctness]
     5434 |                                 std::shared_ptr<LineLayout> ll = view.RetrieveLineLayout(line, *this);
          |                                 ^
          |                                                             const 
    D:\notepad4\scintilla\src\Editor.cxx:5890:2: warning: variable 'll' of type 'std::shared_ptr<LineLayout>' can be declared 'const' [misc-const-correctness]
     5890 |         std::shared_ptr<LineLayout> ll = view.RetrieveLineLayout(line, *this);
          |         ^
          |                                     const 
    D:\notepad4\scintilla\src\Editor.h:389:3: warning: parameter 'options' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]
      389 |                 const XYScrollOptions options, CaretPolicies policies);
          |                 ^~~~~
    D:\notepad4\scintilla\src\Editor.h:508:7: warning: function 'Scintilla::Internal::Editor::Indent' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]
      508 |         void Indent(bool forwards, bool lineTab);
          |              ^
    D:\notepad4\scintilla\src\Editor.cxx:4070:14: note: the definition seen here
     4070 | void Editor::Indent(bool forwards, bool lineIndent) {
          |              ^
    D:\notepad4\scintilla\src\Editor.h:508:7: note: differing parameters are named here: ('lineTab'), in definition: ('lineIndent')
      508 |         void Indent(bool forwards, bool lineTab);
          |              ^                          ~~~~~~~
          |                                         lineIndent
    
     
    • Neil Hodgson

      Neil Hodgson - 2024-08-21
       

      Related

      Commit: [019f8b]

  • Neil Hodgson

    Neil Hodgson - 2024-11-07
    • status: closed --> open
     
  • Zufu Liu

    Zufu Liu - 2025-02-25
    • status: open --> closed
     
  • Neil Hodgson

    Neil Hodgson - 2025-02-26
    • status: closed --> open
     
  • Neil Hodgson

    Neil Hodgson - 2025-02-26

    I reopened this on 2024-11-07 because of the bug reported by the feature author Martijn Laan which has not yet been fixed.

     
    😄
    1

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.