mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Nb/show notebooks as untitled (#6376)
* open notebooks as untitled files and removed the saving to home directory * return just filename without extension since save is adding the .ipynb ext * Changes to open bdc notebooks as untitled docs. Updated tests to align with the changes * changes: not to show untitled file as dirty and cleaned up tests in notebookService * changes to address untitled name conflicts with open editors. * comment cleanup
This commit is contained in:
@@ -35,19 +35,18 @@ export function getAppDataPath() {
|
||||
* @param filePath source notebook file name
|
||||
* @param fileExtension file type
|
||||
*/
|
||||
export function getTargetFileName(filePath: string): string {
|
||||
const targetDirectory = os.homedir();
|
||||
export function findNextUntitledEditorName(filePath: string): string {
|
||||
const fileExtension = path.extname(filePath);
|
||||
const baseName = path.basename(filePath, fileExtension);
|
||||
let targetFileName;
|
||||
let idx = 0;
|
||||
let title = `${baseName}`;
|
||||
do {
|
||||
const suffix = idx === 0 ? '' : `-${idx}`;
|
||||
targetFileName = path.join(targetDirectory, `${baseName}${suffix}${fileExtension}`);
|
||||
title = `${baseName}${suffix}`;
|
||||
idx++;
|
||||
} while (fs.existsSync(targetFileName));
|
||||
} while (azdata.nb.notebookDocuments.findIndex(doc => doc.isUntitled && doc.fileName === title) > -1);
|
||||
|
||||
return targetFileName;
|
||||
return title;
|
||||
}
|
||||
|
||||
export function fileExists(file: string): boolean {
|
||||
|
||||
Reference in New Issue
Block a user