@@ -61,6 +61,7 @@ import {
6161} from '../modules/protection' ;
6262import {
6363 normalizeSelection ,
64+ seletedHighlistByindex ,
6465 syncPrimaryCellActiveFromSelection ,
6566 pasteHandlerOfPaintModel ,
6667} from '../modules/selection' ;
@@ -4930,49 +4931,34 @@ export function handleRowHeaderMouseDown(
49304931 const last = _ . cloneDeep (
49314932 ctx . luckysheet_select_save ?. [ ctx . luckysheet_select_save . length - 1 ] ,
49324933 ) ; // 选区最后一个
4933- if (
4934- ! last ||
4935- _ . isNil ( last . top ) ||
4936- _ . isNil ( last . height ) ||
4937- _ . isNil ( last . row_focus )
4938- ) {
4939- return ;
4940- }
4941-
4942- let _top = 0 ;
4943- let _height = 0 ;
4944- let _rowseleted = [ ] ;
4945- if ( last . top > row_pre ) {
4946- _top = row_pre ;
4947- _height = last . top + last . height - row_pre ;
4948-
4949- if ( last . row [ 1 ] > last . row_focus ) {
4950- last . row [ 1 ] = last . row_focus ;
4934+ if ( last ) {
4935+ const anchor = last . row_focus ?? last . row ?. [ 0 ] ?? row_index ;
4936+ const rStart = Math . min ( anchor , row_index ) ;
4937+ const rEnd = Math . max ( anchor , row_index ) ;
4938+ const bounds = seletedHighlistByindex ( ctx , rStart , rEnd , 0 , col_index ) ;
4939+
4940+ last . row = [ rStart , rEnd ] ;
4941+ last . column = [ 0 , col_index ] ;
4942+ if ( bounds ) {
4943+ last . left = bounds . left ;
4944+ last . width = bounds . width ;
4945+ last . top = bounds . top ;
4946+ last . height = bounds . height ;
4947+ last . left_move = bounds . left ;
4948+ last . width_move = bounds . width ;
4949+ last . top_move = bounds . top ;
4950+ last . height_move = bounds . height ;
49514951 }
4952-
4953- _rowseleted = [ row_index , last . row [ 1 ] ] ;
4954- } else if ( last . top === row_pre ) {
4955- _top = row_pre ;
4956- _height = last . top + last . height - row_pre ;
4957- _rowseleted = [ row_index , last . row [ 0 ] ] ;
4958- } else {
4959- _top = last . top ;
4960- _height = row - last . top - 1 ;
4961-
4962- if ( last . row [ 0 ] < last . row_focus ) {
4963- last . row [ 0 ] = last . row_focus ;
4952+ last . row_select = true ;
4953+ last . column_select = false ;
4954+ last . column_focus = 0 ;
4955+ if ( _ . isNil ( last . row_focus ) ) {
4956+ last . row_focus = anchor ;
49644957 }
49654958
4966- _rowseleted = [ last . row [ 0 ] , row_index ] ;
4959+ ctx . luckysheet_select_save ! [ ctx . luckysheet_select_save ! . length - 1 ] =
4960+ last ;
49674961 }
4968-
4969- last . row = _rowseleted ;
4970-
4971- last . top_move = _top ;
4972- last . height_move = _height ;
4973-
4974- ctx . luckysheet_select_save ! [ ctx . luckysheet_select_save ! . length - 1 ] =
4975- last ;
49764962 } else if ( e . ctrlKey || e . metaKey ) {
49774963 ctx . luckysheet_select_save ?. push ( {
49784964 left : colLocationByIndex ( 0 , ctx . visibledatacolumn ) [ 0 ] ,
@@ -5347,51 +5333,40 @@ export function handleColumnHeaderMouseDown(
53475333 const last = _ . cloneDeep (
53485334 ctx . luckysheet_select_save ?. [ ctx . luckysheet_select_save . length - 1 ] ,
53495335 ) ; // 选区最后一个
5336+ if ( last ) {
5337+ const anchor = last . column_focus ?? last . column ?. [ 0 ] ?? col_index ;
5338+ const cStart = Math . min ( anchor , col_index ) ;
5339+ const cEnd = Math . max ( anchor , col_index ) ;
5340+ const bounds = seletedHighlistByindex (
5341+ ctx ,
5342+ 0 ,
5343+ row_index ,
5344+ cStart ,
5345+ cEnd ,
5346+ ) ;
53505347
5351- let _left = 0 ;
5352- let _width = 0 ;
5353- let _columnseleted = [ ] ;
5354-
5355- if (
5356- ! last ||
5357- _ . isNil ( last . left ) ||
5358- _ . isNil ( last . width ) ||
5359- _ . isNil ( last . column_focus )
5360- ) {
5361- return ;
5362- }
5363-
5364- if ( last . left > col_pre ) {
5365- _left = col_pre ;
5366- _width = last . left + last . width - col_pre ;
5367-
5368- if ( last . column [ 1 ] > last . column_focus ) {
5369- last . column [ 1 ] = last . column_focus ;
5348+ last . column = [ cStart , cEnd ] ;
5349+ last . row = [ 0 , row_index ] ;
5350+ if ( bounds ) {
5351+ last . left = bounds . left ;
5352+ last . width = bounds . width ;
5353+ last . top = bounds . top ;
5354+ last . height = bounds . height ;
5355+ last . left_move = bounds . left ;
5356+ last . width_move = bounds . width ;
5357+ last . top_move = bounds . top ;
5358+ last . height_move = bounds . height ;
53705359 }
5371-
5372- _columnseleted = [ col_index , last . column [ 1 ] ] ;
5373- } else if ( last . left === col_pre ) {
5374- _left = col_pre ;
5375- _width = last . left + last . width - col_pre ;
5376- _columnseleted = [ col_index , last . column [ 0 ] ] ;
5377- } else {
5378- _left = last . left ;
5379- _width = col - last . left - 1 ;
5380-
5381- if ( last . column [ 0 ] < last . column_focus ) {
5382- last . column [ 0 ] = last . column_focus ;
5360+ last . column_select = true ;
5361+ last . row_select = false ;
5362+ last . row_focus = 0 ;
5363+ if ( _ . isNil ( last . column_focus ) ) {
5364+ last . column_focus = anchor ;
53835365 }
53845366
5385- _columnseleted = [ last . column [ 0 ] , col_index ] ;
5367+ ctx . luckysheet_select_save ! [ ctx . luckysheet_select_save ! . length - 1 ] =
5368+ last ;
53865369 }
5387-
5388- last . column = _columnseleted ;
5389-
5390- last . left_move = _left ;
5391- last . width_move = _width ;
5392-
5393- ctx . luckysheet_select_save ! [ ctx . luckysheet_select_save ! . length - 1 ] =
5394- last ;
53955370 } else if ( e . ctrlKey || e . metaKey ) {
53965371 // 选区添加
53975372 ctx . luckysheet_select_save ?. push ( {
0 commit comments