Author Topic: cut-end-line&SmartPaste inserts 1 extra space to 2nd line pasted  (Read 6936 times)

rgknowles

  • Community Member
  • Posts: 7
  • Hero Points: 0
cut-end-line&SmartPaste inserts 1 extra space to 2nd line pasted
« on: September 28, 2006, 12:11:53 AM »
Anyone else see this (or know how to fix it) in V11 (worked fine in V9).  It is really annoying to have to 'fix up' pasted lines. 

When editting C++ code, I cut 2 (or more) lines (using cut-end-line in emacs mode, bound to ^K) and whenever I paste them (using either paste or emacs-paste) the second (and additional) lines have a one character extra indentation.  When I view the clipboard via the view option in list-clipboards, there is no extra space.  If I disable SmartPaste (in File Extension Setup) then the paste is okay (but not smart).  If I use cut (S-DEL) instead of cut-end-line the paste is okay.

rgknowles

  • Community Member
  • Posts: 7
  • Hero Points: 0
Re: cut-end-line&SmartPaste inserts 1 extra space to 2nd line pasted
« Reply #1 on: October 05, 2006, 04:59:22 PM »
Anyone have a hint as to where I should look to try and fix this?

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2903
  • Hero Points: 153
Re: cut-end-line&SmartPaste inserts 1 extra space to 2nd line pasted
« Reply #2 on: October 05, 2006, 06:10:59 PM »
Is it possible that the indent amount in file extension setup does not match the file that you are working on?

rgknowles

  • Community Member
  • Posts: 7
  • Hero Points: 0
Re: cut-end-line&SmartPaste inserts 1 extra space to 2nd line pasted
« Reply #3 on: October 06, 2006, 06:51:25 AM »
Nope.  Maybe I should give an example
Given
{
    a = 0;
    b = 1;
    c = 2;
    d = 3;
}
With cursor at column 0 of the 'b' line, I execute cut-end-line 4 times and have this (cursor now in col 0 of 'd = 3;' line):
{
    a = 0;
    d = 3;
}
Now if I paste (or emacs-paste) the cut lines back I get:
{
    a = 0;
    b = 1;
     c = 2;
    d = 3;
}
Note the 'c' line has one extra space of indent.  This is true regardless of the syntax indent value.

If I "cut-end-line" more lines (eg: all 4 assignment lines), only the first line is indented correctly, all other lines have the one extra space indent:
{
    a = 0;
     b = 1;
     c = 2;
     d = 3;
}
« Last Edit: October 06, 2006, 07:00:50 AM by rgknowles »

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2903
  • Hero Points: 153
Re: cut-end-line&SmartPaste inserts 1 extra space to 2nd line pasted
« Reply #4 on: October 06, 2006, 01:18:46 PM »
Thanks for the example.  I was unable to reproduce this using 11.0.2 (even in Emacs emulation).

Do you have the 11.0.2 patch?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6934
  • Hero Points: 531
Re: cut-end-line&SmartPaste inserts 1 extra space to 2nd line pasted
« Reply #5 on: October 06, 2006, 07:11:48 PM »
You don't need emacs emulation to reproduce this.  I wrote the code for this and I'm pretty sure is a case that it is supposed to be handled.  I will look into it. 

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6934
  • Hero Points: 531
Re: cut-end-line&SmartPaste inserts 1 extra space to 2nd line pasted
« Reply #6 on: October 06, 2006, 07:55:45 PM »
Replace your v11.0.2 code for cut_end_line in clipbd.e with the code below.  Don't forget to load the new module Macro>Load Module... The problem was that the start column for the clipboard wasn't being stored.

_command cut_end_line(boolean push=true) name_info(','VSARG2_TEXT_BOX|VSARG2_REQUIRES_EDITORCTL)
{
   _str cmdname=name_name(last_index('','C'));
   boolean executed_from_key=name_name(last_index()):==translate(cmdname,'-','_');
   typeless mark_pos=0;
   typeless mark='';
   _str line='';
   _str rest='';
   _str key='';
   int col=0;
   int i,count=1;
   typeless status=0;
   if ( command_state() ) {
      get_command(line,col);
      rest=substr(line,col);
      if ( rest:=='' ) return(0);
      line=substr(line,1,col-1);
      set_command(line);
      prev_index(0,'C');last_index(0,'C');
      col=0;
   } else {
      if (_on_line0()) {
         return(0);
      }
      count=1;
      if (executed_from_key) {
         key=last_event();
         while (test_event('r'):==key && count<30) {
            ++count;get_event('r');
         }
      }
      mark=_alloc_selection();
      if (mark<0) {
         status=TOO_MANY_SELECTIONS_RC;
         message(get_message(status));
         return(status);
      }
      save_pos(mark_pos);
      _select_char(mark);col=p_col;
      for (i=1;i<=count;++i) {
         if ( p_col>_text_colc(0,'E')) {
            if(down()){
               count=i-1;
               break;
            }
            _begin_line();
         } else {
            _TruncEndLine();
         }
      }
      _select_char(mark);
      restore_pos(mark_pos);
      if (count<1) {
         _free_selection(mark);
         message(get_message(BOTTOM_OF_FILE_RC));
         return(BOTTOM_OF_FILE_RC);
      }
   }
   if ( push && name_name(prev_index('','C'))!='cut-end-line' ) {
      status=push_clipboard_itype('CHAR','',col,_isEditorCtl()?p_UTF8:_UTF8());
      if ( status ) return(status);
   }
   if (mark=='') {
      return(append_clipboard_text(rest));
   }
   status=append_cut2(mark,true);
   _free_selection(mark);
   for(;;) {
      erase_end_line();
      if (!(--count)) break;
      _undo('s');
   }
   return(status);

}

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6934
  • Hero Points: 531
Re: cut-end-line&SmartPaste inserts 1 extra space to 2nd line pasted
« Reply #7 on: October 09, 2006, 01:43:17 PM »
Looks like the code snippet I cut/pasted above got smilied.  Here is the same code via an attachment.