Menu

#2463 ChangeCaseOfSelection should ignore protected ranges

Bug
open
nobody
5
2025-04-27
2025-02-25
JMairboeck
No

Currently, Editor::ChangeCaseOfSelection doesn't check for protected ranges and therefore they can be modified by the UpperCase and LowerCase commands (i.e. the Ctrl+[Shift]+U key bindings by default).

These commands should not affect protected ranges.

Discussion

  • JMairboeck

    JMairboeck - 2025-02-25

    I made a trivial patch which disables the functionality when there are protected styles in the range.

    Ideally, the case change should only occur in the unprotected parts instead. That would require splitting the selection into multiple parts according to the protection state of the affected styles. Is there such a function available?

     
  • Zufu Liu

    Zufu Liu - 2025-02-26
    • labels: --> Scintilla, selection
     
  • Zufu Liu

    Zufu Liu - 2025-02-27

    How about following:

        for (size_t r=0; r<sel.Count(); r++) {
            SelectionRange current = sel.Range(r);
            if (RangeContainsProtected(current)) {
                continue;
            }
            SelectionRange currentNoVS = current;
            currentNoVS.ClearVirtualSpace();
    

    or just:

    void Editor::ChangeCaseOfSelection(CaseMapping caseMapping) {
        if (SelectionContainsProtected()) {
            return;
        }
        UndoGroup ug(pdoc);
    
     
  • Neil Hodgson

    Neil Hodgson - 2025-02-27

    I don't understand the use case where the user wants only part of the command to succeed. What is the role of protection in your application?

    If there is no strong motivation then its not worth the added complexity.

     
  • Neil Hodgson

    Neil Hodgson - 2025-02-28
    • labels: Scintilla, selection --> Scintilla, selection, protected
    • status: open --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2025-02-28

    Committed the above simple change as [8a8200].

     

    Related

    Commit: [8a8200]

  • Neil Hodgson

    Neil Hodgson - 2025-04-02
    • status: open-fixed --> closed-fixed
     
  • JMairboeck

    JMairboeck - 2025-04-25

    Sorry for not responding sooner, I had missed the e-mail notifications from SourceForge. We use protected ranges for base64-encoded metadata in comments. When changing the case of base64 data, that breaks and the metadata can't be decoded any more, so we have to exclude these ranges from the case changes.

     
  • Neil Hodgson

    Neil Hodgson - 2025-04-27
    • status: closed-fixed --> open
     

Log in to post a comment.

MongoDB Logo MongoDB