Skip to content

Commit

Permalink
CE: Fix click on none code line space
Browse files Browse the repository at this point in the history
  • Loading branch information
jxarco committed Jan 31, 2024
1 parent a5d8d63 commit dcd4b5d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions build/components/codeeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1611,19 +1611,16 @@ class CodeEditor {

processMouse( e ) {

if( !e.target.classList.contains('code') ) return;
if( !e.target.classList.contains('code') && !e.target.classList.contains('codetabsarea') ) return;
if( !this.code ) return;

var cursor = this._getCurrentCursor();
var code_rect = this.code.getBoundingClientRect();
var mouse_pos = [(e.clientX - code_rect.x), (e.clientY - code_rect.y)];

// Discard out of lines click...
if( e.type != 'contextmenu' )
{
var ln = (mouse_pos[1] / this.lineHeight)|0;
if(this.code.lines[ ln ] == undefined) return;
}
var ln = ( mouse_pos[ 1 ] / this.lineHeight ) | 0;
if( ln < 0 ) return;

if( e.type == 'mousedown' )
{
Expand Down Expand Up @@ -1731,8 +1728,8 @@ class CodeEditor {
var position = [( e.clientX - code_rect.x ) + this.getScrollLeft(), (e.clientY - code_rect.y) + this.getScrollTop()];
var ln = (position[ 1 ] / this.lineHeight)|0;

if( this.code.lines[ ln ] == undefined )
return;
// Check out of range line
ln = Math.min( ln, this.code.lines.length - 1 );

var ch = ( ( position[ 0 ] - parseInt( this.xPadding ) + 3) / this.charWidth )|0;
var string = this.code.lines[ ln ].slice( 0, ch );
Expand Down

0 comments on commit dcd4b5d

Please sign in to comment.