Action

Next Sentence

Last update over 4 years ago - Unlisted

Steps

  • script

    //Get the curret cursor position based on the end of the current selection
    let intCurrentPosition = editor.getSelectedRange()[0] + editor.getSelectedRange()[1];
    
    //Find the next sentence ends
    let intNextPeriodDSpace = editor.getText().indexOf(".  ",intCurrentPosition);
    let intNextPeriodSSpace = editor.getText().indexOf(". ",intCurrentPosition);
    let intNextLineEnd = editor.getText().indexOf("\n", intCurrentPosition);
    
    //Initialise
    let intNewPosition = editor.getText().length;
    
    //Incrementally check positions
    if(intNextPeriodSSpace > 0 && intNextPeriodSSpace <= intNewPosition) intNewPosition = intNextPeriodSSpace + 2;
    if(intNextPeriodDSpace > 0 && intNextPeriodDSpace <= (intNewPosition + 1)) intNewPosition = intNextPeriodDSpace + 3;
    if(intNextLineEnd > 0 && intNextLineEnd < intNewPosition) intNewPosition = intNextLineEnd + 1;
    
    //Set new position
    editor.setSelectedRange(intNewPosition, 0);
    

Options

  • After Success Default
    Notification Error
    Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.