1- // Copyright (c) Microsoft Corporation.
2- // Licensed under the MIT License.
3-
41import { injectable , inject } from 'inversify' ;
52import {
63 commands ,
@@ -17,7 +14,6 @@ import { logger } from '../../platform/logging';
1714import { IExtensionSyncActivationService } from '../../platform/activation/types' ;
1815import { IDisposableRegistry } from '../../platform/common/types' ;
1916import { Commands } from '../../platform/common/constants' ;
20- import { noop } from '../../platform/common/utils/misc' ;
2117import { chainWithPendingUpdates } from '../../kernels/execution/notebookUpdater' ;
2218import {
2319 DeepnoteBigNumberMetadataSchema ,
@@ -102,7 +98,11 @@ export function getNextDeepnoteVariableName(cells: NotebookCell[], prefix: 'df'
10298
10399 const maxDeepnoteVariableNamesSuffixNumber =
104100 deepnoteVariableNames . reduce < number | null > ( ( acc , name ) => {
105- const m = name . match ( new RegExp ( `^${ prefix } _(\\d+)$` ) ) ;
101+ if ( ! name . startsWith ( prefix ) ) {
102+ return acc ;
103+ }
104+
105+ const m = name . match ( / _ ( \d + ) $ / ) ;
106106 if ( m == null ) {
107107 return acc ;
108108 }
@@ -189,9 +189,14 @@ export class DeepnoteNotebookCommandListener implements IExtensionSyncActivation
189189 } ;
190190 const nbEdit = NotebookEdit . insertCells ( insertIndex , [ newCell ] ) ;
191191 edit . set ( document . uri , [ nbEdit ] ) ;
192- } ) . then ( ( ) => {
193- editor . selection = new NotebookRange ( insertIndex , insertIndex + 1 ) ;
194- } , noop ) ;
192+ } ) . then (
193+ ( ) => {
194+ editor . selection = new NotebookRange ( insertIndex , insertIndex + 1 ) ;
195+ } ,
196+ ( error ) => {
197+ logger . error ( 'Error inserting SQL block' , error ) ;
198+ }
199+ ) ;
195200 }
196201
197202 private addBigNumberChartBlock ( ) : void {
@@ -223,9 +228,14 @@ export class DeepnoteNotebookCommandListener implements IExtensionSyncActivation
223228 newCell . metadata = metadata ;
224229 const nbEdit = NotebookEdit . insertCells ( insertIndex , [ newCell ] ) ;
225230 edit . set ( document . uri , [ nbEdit ] ) ;
226- } ) . then ( ( ) => {
227- editor . selection = new NotebookRange ( insertIndex , insertIndex + 1 ) ;
228- } , noop ) ;
231+ } ) . then (
232+ ( ) => {
233+ editor . selection = new NotebookRange ( insertIndex , insertIndex + 1 ) ;
234+ } ,
235+ ( error ) => {
236+ logger . error ( 'Error inserting big number chart block' , error ) ;
237+ }
238+ ) ;
229239 }
230240
231241 private addInputBlock ( blockType : InputBlockType ) : void {
@@ -260,8 +270,13 @@ export class DeepnoteNotebookCommandListener implements IExtensionSyncActivation
260270 newCell . metadata = metadata ;
261271 const nbEdit = NotebookEdit . insertCells ( insertIndex , [ newCell ] ) ;
262272 edit . set ( document . uri , [ nbEdit ] ) ;
263- } ) . then ( ( ) => {
264- editor . selection = new NotebookRange ( insertIndex , insertIndex + 1 ) ;
265- } , noop ) ;
273+ } ) . then (
274+ ( ) => {
275+ editor . selection = new NotebookRange ( insertIndex , insertIndex + 1 ) ;
276+ } ,
277+ ( error ) => {
278+ logger . error ( 'Error inserting input block' , error ) ;
279+ }
280+ ) ;
266281 }
267282}
0 commit comments