1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

Cli: Fixes #2039: Handle paths with spaces for text editor

This commit is contained in:
Laurent Cozic 2019-11-01 22:42:05 +00:00
parent d2a7e46c1a
commit 689a12cdfb

View File

@ -1,5 +1,6 @@
const fs = require('fs-extra');
const { BaseCommand } = require('./base-command.js');
const { splitCommandString } = require('lib/string-utils.js');
const { uuid } = require('lib/uuid.js');
const { app } = require('./app.js');
const { _ } = require('lib/locale.js');
@ -53,7 +54,7 @@ class Command extends BaseCommand {
// -------------------------------------------------------------------------
let editorPath = textEditorPath();
let editorArgs = editorPath.split(' ');
let editorArgs = splitCommandString(editorPath);
editorPath = editorArgs[0];
editorArgs = editorArgs.splice(1);
@ -71,30 +72,18 @@ class Command extends BaseCommand {
this.logger().info('Disabling fullscreen...');
app()
.gui()
.showModalOverlay(_('Starting to edit note. Close the editor to get back to the prompt.'));
await app()
.gui()
.forceRender();
const termState = app()
.gui()
.termSaveState();
app().gui().showModalOverlay(_('Starting to edit note. Close the editor to get back to the prompt.'));
await app().gui().forceRender();
const termState = app().gui().termSaveState();
const spawnSync = require('child_process').spawnSync;
const result = spawnSync(editorPath, editorArgs, { stdio: 'inherit' });
if (result.error) this.stdout(_('Error opening note in editor: %s', result.error.message));
app()
.gui()
.termRestoreState(termState);
app()
.gui()
.hideModalOverlay();
app()
.gui()
.forceRender();
app().gui().termRestoreState(termState);
app().gui().hideModalOverlay();
app().gui().forceRender();
// -------------------------------------------------------------------------
// Save the note and clean up