Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
phil-blain opened this issue Nov 8, 2024 · 1 comment

Comments

@phil-blain
Copy link

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.

@blais
Copy link
Owner

blais commented Nov 8, 2024

This project is almost 25 years old and I haven't changed it in a while - years (I use tmux-based console diffing tools more these days). You're welcome to send me a patch; unless it looks egregiously bad I will rubberstamp it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants