Skip to content

"Edit right/left file" do not work with EDITOR=vim, or any other console editor #36

@phil-blain

Description

@phil-blain

The command used to "Edit right file" or "Edit left" file is hardcoded to xterm -e vi if EDITOR is not set in the environment:

xxdiff/src/resources.cpp

Lines 335 to 341 in 50cb42b

const char* editor = getenv( "EDITOR" );
if ( editor != 0 ) {
_commands[ CMD_EDIT ] = QString::fromLocal8Bit( editor );
}
else {
_commands[ CMD_EDIT ] = "xterm -e vi";
}

This is not ideal since EDITOR is meant (by old convention) to refer to a command-line editor like vi or vim, not a graphical program. When these xxdiff menu options are used with EDITOR=vim, nothing happens, which is very confusing. The error message at the end of XxApp::editFIle is not shown, because the if ( ! _editProc[bufIdx]->waitForStarted() ) block is not entered:

xxdiff/src/app.cpp

Lines 2723 to 2738 in 50cb42b

if ( _editProc[bufIdx] == NULL ) {
_editProc[bufIdx] = new QProcess;
connect( _editProc[bufIdx], SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(redoDiff()) );
}
_editProc[bufIdx]->start( executable, args );
if ( ! _editProc[bufIdx]->waitForStarted() ) {
QString text;
{
QTextStream oss( &text );
oss << "There has been an error spawning the editor ("
<< executable << "): "
<< _editProc[bufIdx]->errorString() << Qt::endl;
}
new XxSuicideMessageBox(
_mainWindow, "Error.", text, QMessageBox::Warning
);

I didn't debug further, but it makes sense that invoking vim outside a terminal would not work. I would have expected the error message to be shown, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions