WordPress.org

Make WordPress Core

Changeset 41992


Ignore:
Timestamp:
10/24/17 16:34:12 (3 weeks ago)
Author:
westonruter
Message:

Code Editor: Define default gutters and toggle lint markers based on changes to lint option.

Explicitly define gutters in base defaultSettings to improve merges of multiple calls to wp_enqueue_code_editor().

Props westonruter, georgestephanis for testing.
Amends [41974].
See #12423.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/code-editor.js

    r41974 r41992  
    137137        // Keep lint options populated. 
    138138        editor.on( 'optionChange', function( cm, option ) { 
    139             var options; 
     139            var options, gutters, gutterName = 'CodeMirror-lint-markers'; 
    140140            if ( 'lint' !== option ) { 
    141141                return; 
    142142            } 
     143            gutters = editor.getOption( 'gutters' ) || []; 
    143144            options = editor.getOption( 'lint' ); 
    144145            if ( true === options ) { 
     146                if ( ! _.contains( gutters, gutterName ) ) { 
     147                    editor.setOption( 'gutters', [ gutterName ].concat( gutters ) ); 
     148                } 
    145149                editor.setOption( 'lint', getLintOptions() ); // Expand to include linting options. 
     150            } else if ( ! options ) { 
     151                editor.setOption( 'gutters', _.without( gutters, gutterName ) ); 
    146152            } 
    147153 
  • trunk/src/wp-includes/general-template.php

    r41974 r41992  
    31583158            ), 
    31593159            'direction' => 'ltr', // Code is shown in LTR even in RTL languages. 
     3160            'gutters' => array(), 
    31603161        ), 
    31613162        'csslint' => array( 
Note: See TracChangeset for help on using the changeset viewer.