#662 wrong file status after execute shell command "spell"

open
nobody
None
5
2010-01-29
2010-01-29
Anonymous
No

I think any nedit version has the same problem:

1) open a text file with nedit;
2) choose from menu "Shell-->spell". Once the spell window pop up, choose "abort";
3) the content in nedit window should remain unmodified, however, the file status is changed to "modified".

Discussion

  • Nobody/Anonymous

    it seems all the shell commands have the same problem: no matter if the file content is changed, the file status is always "modified".

     
  • Nobody/Anonymous

    is this an easy-fix problem? My knowledge about graphic programming is very limited. If it is easy, can any developer give me some clues so that I can try by myself?

    Thanks.

     
  • Nobody/Anonymous

    First thing to check is how the Shell->Spell operation is defined. Use Preferences-> Default Settings-> Customize Menus-> Shell Menu... to open the Shell menu definition dialog. In the list, find the entry corresponding to Spell, and select it. Notice the Command Output radio buttons. If the "same document" button is active, a replace operation will be executed even if this has no effect on the content of your document. This could explain your issue. You can test this by adding a new entry which invokes the command "cat" which copies its input to its output. I've just tried it and the effect is exactly as you describe. I don't know what your spell command actually does, but if "Abort"ing it simply copies its input to its output, that would explain the modification.

     
  • Nobody/Anonymous

    First of all thanks for the reply from the reply.

    It seems the attached fix can resolve this problem, but I am not sure if the fix has any drawbacks.

    The idea is to compare two text bufs in "finishCmdExecution()" in "shell.c", the input and the output to the shell command(s). If they are identical then the following "safeBufReplace()" won't be invoked.

    ===============================================================
    --- shell_v1.44.c 2010-02-13 11:45:14.000000000 -0600
    +++ shell_new.c 2010-02-13 11:55:44.000000000 -0600
    @@ -796,11 +796,11 @@
    static void finishCmdExecution(WindowInfo *window, int terminatedOnError)
    {
    shellCmdInfo *cmdData = window->shellCmdData;
    textBuffer *buf;
    int status, failure, errorReport, reselectStart, outTextLen, errTextLen;
    - int resp, cancel = False, fromMacro = cmdData->fromMacro;
    + int resp, cancel = False, reallytoReplace = True, fromMacro = cmdData->fromMacro;
    char *outText, *errText = NULL;

    /* Cancel any pending i/o on the file descriptors */
    if (cmdData->stdoutInputID != 0)
    XtRemoveInput(cmdData->stdoutInputID);
    @@ -814,10 +814,17 @@
    if (cmdData->flags & ERROR_DIALOGS)
    close(cmdData->stderrFD);
    if (cmdData->inPtr != NULL)
    close(cmdData->stdinFD);

    + /* Assemble the output from the stdout streams into null
    + terminated strings, and free the buffer lists used to collect it */
    + outText = coalesceOutput(&cmdData->outBufs, &outTextLen);
    +
    + /* Check if the shell command really changed the content of input */
    + reallytoReplace = strcmp(cmdData->input, outText);
    +
    /* Free the provided input text */
    XtFree(cmdData->input);

    /* Cancel pending timeouts */
    if (cmdData->flushTimeoutID != 0)
    @@ -903,18 +910,22 @@
    if (!BufSubstituteNullChars(outText, outTextLen, buf)) {
    fprintf(stderr,"nedit: Too much binary data in shell cmd output\n");
    outText[0] = '\0';
    }
    if (cmdData->flags & REPLACE_SELECTION) {
    - reselectStart = buf->primary.rectangular ? -1 : buf->primary.start;
    - BufReplaceSelected(buf, outText);
    - TextSetCursorPos(cmdData->textW, buf->cursorPosHint);
    - if (reselectStart != -1)
    - BufSelect(buf, reselectStart, reselectStart + strlen(outText));
    + if (reallytoReplace) {
    + reselectStart = buf->primary.rectangular ? -1 : buf->primary.start;
    + BufReplaceSelected(buf, outText);
    + TextSetCursorPos(cmdData->textW, buf->cursorPosHint);
    + if (reselectStart != -1)
    + BufSelect(buf, reselectStart, reselectStart + strlen(outText));
    + }
    } else {
    - safeBufReplace(buf, &cmdData->leftPos, &cmdData->rightPos, outText);
    - TextSetCursorPos(cmdData->textW, cmdData->leftPos+strlen(outText));
    + if (reallytoReplace) {
    + (buf, &cmdData->leftPos, &cmdData->rightPos, outText);
    + TextSetCursorPos(cmdData->textW, cmdData->leftPos+strlen(outText));
    + }
    }
    }

    /* If the command requires the file to be reloaded afterward, reload it */
    if (cmdData->flags & RELOAD_FILE_AFTER)
    ===============================================================

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks