Author Topic: Still seeing text unselect itself  (Read 1223 times)

texasaggie97

  • Community Member
  • Posts: 20
  • Hero Points: 4
Still seeing text unselect itself
« on: January 23, 2018, 08:20:34 pm »
I am still seeing the issue reported in the beta.

This is happening often enough that it is getting pretty annoying. It happens several times a day recently. I highlight something so I can copy it or replace it and then I end up copying the whole line or inserting it instead of replacing it.

Is there anything I can do to help troubleshoot this?

I am using v22.0.0.9 x64 on Windows 10 1709 with hotfix revision 13.

Graeme

  • Senior Community Member
  • Posts: 2091
  • Hero Points: 252
Re: Still seeing text unselect itself
« Reply #1 on: January 24, 2018, 06:18:11 am »
Try turning off background tagging or notifications or product improvement participation.
Do you use the mouse or keyboard to highlight text?
Do you use the shift arrow keys - if so, what key binding do you have for them?
How long does the text stay highlighted for before it disappears?
Does the status bar notice that text has been highlighted?

texasaggie97

  • Community Member
  • Posts: 20
  • Hero Points: 4
Re: Still seeing text unselect itself
« Reply #2 on: January 24, 2018, 05:28:39 pm »
Quote
Try turning off background tagging or notifications or product improvement participation.
Okay, I have turned off background tagging and turned off participate in the product improvement home. Update: Even with these turned off, I just saw it again multiple times.
Quote
Do you use the mouse or keyboard to highlight text?
I always use ctrl-c and ctrl-v. Sometimes I use the mouse to highlight, sometimes I use the keyboard
Quote
Do you use the shift arrow keys - if so, what key binding do you have for them?
I am using shift arrow keys. I am using the CUA bindings with no changes
Quote
How long does the text stay highlighted for before it disappears?
Half a second maybe? Long enough to see that it was highlighted, but short enough I have to be really quick with the ctrl-c to copy it
Quote
Does the status bar notice that text has been highlighted?
I don't know. I will try to pay attention, but it is for a short period of time Update: I just saw it again and yes, the status bar does see it as selected.

Also, I noticed I was not using the latest (I thought I was) so I upgraded. Current about:
Code: [Select]
SlickEdit Pro 2017 (v22.0.1.0 64-bit)

Serial number: WB945742
Licensed number of users: Single user
License file: C:\ProgramData\slickedit\22\slickedit.lic

Build Date: January 22, 2018
Emulation: CUA

OS: Windows 10 x64
OS Version: 10.00.0 
Memory: 21% Load, 7034MB/32708MB Physical, 8219MB/65476MB Page File, 632MB/134217727MB Virtual
Shell Information: C:\WINDOWS\system32\cmd.exe /q
Screen Size: 1920 x 1080, 1050 x 1680, 1050 x 1680

Project Type: Makefile
Language: .py (Python)
Encoding: Automatic

Installation Directory: C:\Program Files\SlickEdit Pro 22\ (non-removable drive,NTFS,45348MB free)
Configuration Directory: C:\Users\msilva\Documents\My SlickEdit Config\22.0.1\ (non-removable drive,NTFS,45348MB free)
Migrated from: C:\Users\msilva\Documents\My SlickEdit Config\22.0.0\

Hotfixes:
C:\Users\msilva\Documents\My SlickEdit Config\22.0.1\hotfixes\hotfix_se2201_3_cumulative.zip (Revision: 3)
« Last Edit: January 24, 2018, 05:42:08 pm by texasaggie97 »

Graeme

  • Senior Community Member
  • Posts: 2091
  • Hero Points: 252
Re: Still seeing text unselect itself
« Reply #3 on: January 25, 2018, 08:42:04 pm »
I'll have a go at writing a timer callback to capture the selection that gets lost.  It might also be useful to run process monitor from sys internals in case it shows something.

Do you have any idea if the cursor position is changed when the highlighting is lost, or whether the focus changes?
Is there anything special about your machine  - is it particularly fast?  Do you have slickedit windows across all three monitors? 

Graeme

  • Senior Community Member
  • Posts: 2091
  • Hero Points: 252
Re: Still seeing text unselect itself
« Reply #4 on: January 26, 2018, 12:01:48 pm »
I've tried the following code - it's not working correctly yet.  _kill_timer doesn't work and the timer seems to run faster than it should.  I don't understand selection functions very well.  I'll try slickedit support if I can't figure it out.

Code: [Select]
#include "slick.sh"


#pragma option(strictsemicolons,on)
#pragma option(strict,on)
#pragma option(autodecl,off)
#pragma option(strictparens,on)


static int catch_selection_timer;

static bool was;

static typeless last_mark;
static int countdown;
static bool xstop;

static int xselect_active(_str markid='')
{
   if ( _select_type(markid)!='' ) {
      int first_col,last_col,buf_id;
      _get_selinfo(first_col,last_col,buf_id,markid);
      if ( buf_id==_mdi.p_child.p_buf_id ) {
         return(MARK_SEARCH);
      }
   }
   return(0);

}


static void catch_selection_callback()
{
   if ( xselect_active() && !xstop ) {
      if ( was ) {
         _free_selection(last_mark);
      }
      say('ysys');
      save_selection(last_mark);
      was = true;
      countdown = 50;
   }
   else if ( countdown > 0 ) {
      --countdown;
   }

}


_command void restore_lost_selection() name_info(',')
{
   if ( countdown > 0 ) {
      xstop = true;
      restore_selection(last_mark);
   }
}


static void start_timer()
{
   catch_selection_timer = _set_timer(100, catch_selection_callback);
}


_command void xgp1() name_info(',')
{
   save_selection(last_mark);
}


_command void xgp2() name_info(',')
{
   xstop = true;
   _kill_timer(catch_selection_timer);
}


_command void xgp4() name_info(',')
{
   restore_selection(last_mark);
}


_command void xgp3() name_info(',')
{
   start_timer();
   xstop = false;
}


definit()
{
   start_timer();
   xstop = false;
   countdown = 0;
}


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4139
  • Hero Points: 288
Re: Still seeing text unselect itself
« Reply #5 on: January 26, 2018, 03:27:00 pm »
If you load this macro multiple times, you're going to get a new timer each time. To avoid this, make the timer handle global (not static) and the definit() code needs to be something like this:

Code: [Select]
int gcatch_selection_timer;
definit() {
   if (arg(1) == 'L') {
      _kill_timer((int)gcatch_selection_timer);
      // Create timer or temp view if necessary
      start_timer();
      return;
   }
   start_timer();
}

Graeme

  • Senior Community Member
  • Posts: 2091
  • Hero Points: 252
Re: Still seeing text unselect itself
« Reply #6 on: January 27, 2018, 10:28:29 pm »
If you load this macro multiple times, you're going to get a new timer each time. To avoid this, make the timer handle global (not static) and the definit() code needs to be something like this:

Awesome, thanks.
(I think this needs to go in the docs.  One day I might start a OneNote notebook or wiki for slickedit.)



Graeme

  • Senior Community Member
  • Posts: 2091
  • Hero Points: 252
Re: Still seeing text unselect itself
« Reply #7 on: January 27, 2018, 10:55:04 pm »
I am still seeing the issue reported in the beta.

This is happening often enough that it is getting pretty annoying. It happens several times a day recently. I highlight something so I can copy it or replace it and then I end up copying the whole line or inserting it instead of replacing it.

Is there anything I can do to help troubleshoot this?

I am using v22.0.0.9 x64 on Windows 10 1709 with hotfix revision 13.

There's a possibility that deleting all of the state files (vslick.sta and any hotfix state files) in your configuration folder (with slick closed) will fix the problem  - or maybe start a brand new configuration folder and import your settings.  Quite often an obscure problem can be fixed just by deleting the state file.  There's lots of "pcode" and data in the state file.

If you've upgraded to V22.0.1 I suspect your current state file is not carrying over any "corruption" that happened during the beta testing but I don't know.

If you're still getting the problem and you want to try a workaround you could load the code below.  It uses a 100 millisecond timer callback to remember any selection you have active.  You could bind Ctrl-C to the function check_selection_and_copy.  Under certain conditions it restores a lost selection and positions the cursor at the end of the selection instead of doing the copy.  You can then press Ctrl-C again to do the actual copy - unless the selection has disappeared before you hit Ctrl-C a second time.

An alternative solution is to have a command that sets the start point of where you want to copy from, then move the cursor to the end-point, then call a function to copy from the start point to the end point.

There's a chance the slick C profiler might help with finding the problem - see the profiling option in the macro menu.  It's purpose is to show how much time each slick C function is using.  If you use the save option it dumps the captured data into a tab/space separated text file.
Slickedit has a major timer callback of its own -  _as_callback() in autosave.e.  If you enable profiling and do nothing you'll still get lots of stuff, mostly because of this callback I think.  With some effort you might be able to determine whether the _as_callback is when the selection is getting lost.  It might not be where the problem is as I think the core C++ code is doing lots of stuff behind the scenes as well, probably including garbage collection - not sure.  One time when I was playing with the yy1() and yy2() functions below, I called yy2 a second time with no call to yy1 and noticed that the selection got restored but disappeared half a second later by itself - as if the core code was cleaning up the selection mark thing.

That reminds me  - do you find that if you select a few characters, then some more characters, that the selection of the first few characters can get lost or is it only when you pause that the selection gets lost?


Code: [Select]
#include "slick.sh"


#pragma option(strictsemicolons,on)
#pragma option(strict,on)
#pragma option(autodecl,off)
#pragma option(strictparens,on)


int gcatch_selection_timer;
int def_no_lost_selection_check;

static bool selection_was_saved;

static typeless last_mark;
static int countdown;
static bool xstop;
static int xline;

_command void spf() name_info(',')
{
   profile('on');
}

_command void spe() name_info(',')
{
   profile('view');
}

static int xselect_active(_str markid='')
{
   if ( _select_type(markid)!='' ) {
      int first_col,last_col,buf_id;
      _get_selinfo(first_col,last_col,buf_id,markid);
      if ( buf_id==_mdi.p_child.p_buf_id ) {
         return(MARK_SEARCH);
      }
   }
   return(0);
}


static void xcatch_selection_callback()
{
   if (!def_use_timers || !_use_timers) {
      return;
   }

   if ( xselect_active() && !xstop ) {
      if ( selection_was_saved ) {
         _free_selection(last_mark);
      }
      //say('ysys');
      xline = _mdi.p_child.p_line;
      save_selection(last_mark);
      selection_was_saved = true;
      countdown = 100;  // remember selection for ten seconds
   }
   else if ( countdown > 0 ) {
      --countdown;
   }
}

static void start_timer()
{
   gcatch_selection_timer = _set_timer(100, xcatch_selection_callback);
   xstop = false;
}


_command void restore_lost_selection() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL)
{
   if ( selection_was_saved) {
      restore_selection(last_mark);
      _end_select();
      save_selection(last_mark);
   }
}


_command void check_selection_and_copy() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL)
{
   if ( countdown <= 0 || !selection_was_saved || xselect_active()
                          || def_no_lost_selection_check || (xline != _mdi.p_child.p_line)  ) {
      copy_to_clipboard();
      return;
   }
   restore_selection(last_mark);
   _end_select();
   save_selection(last_mark);
}



typeless ymark;
_command void yy1() name_info(',')
{
   say('1 ' :+ ymark);
   save_selection(ymark);
   say(ymark);
}

_command void yy2() name_info(',')
{
   say('2 ' :+ ymark);
   restore_selection(ymark);
   say(ymark);
}


definit()
{
   countdown = 0;
   if (arg(1) == 'L') {
      _kill_timer((int)gcatch_selection_timer);
      if ( selection_was_saved ) {
         _free_selection(last_mark);
         selection_was_saved = false;
      }
      // Create timer or temp view if necessary
      start_timer();
      return;
   }
   selection_was_saved = false;
   start_timer();
}

« Last Edit: January 27, 2018, 10:57:19 pm by Graeme »

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2332
  • Hero Points: 308
Re: Still seeing text unselect itself
« Reply #8 on: January 29, 2018, 06:03:22 pm »
@texasaggie97:

Some thoughts on debugging this:

1)  Since you are using an unaltered CUA emulation, you will probably want to start SlickEdit with a default configuration to rule out any side-effects that are configuration specific to you.
   <instdir>/win/vs.exe -sc C:\Temp\pyselect

2) Determine if you can reproduce the problem with a default configuration.  If so, that will make it a lot easier to get to the bottom of things.  If not, you'll probably want to make a backup of your configuration directory, do the following tests, then restore your configuration.

3) Step one, based on your description of the problem is to determine if the problem is due to a timer callback.  Go to Macro > Set Slick-C Variable... and set def_use_timers = 0.  This will turn off almost all of the timer callbacks.  See if you can reproduce the problem with the timers turned off.

3a) If you can reproduce the problems with the timers turned off, proceed to question 4.

3b) If not, follow the following steps.  First, turn def_use_timers back on.  Verify that the problem still happens after each step.  Stop once you can no longer reproduce the problem.  The last thing you turned off or closed must have been the culprit.

3c) Are you running a background search when this problem happens?  Does the problem still happen if you stop any running background searches (From the Find tool window > Stop).

3d) Are you debugging Python when this problem happens?  Does the problem still happen when the debugger is not running?  Debug > Stop

3e) Turn off all background tagging options.  I think you tried this already, and it is very unlikely to be the problem anyway, but we're trying to be methodical here.  Tools > Options > Editing > Background Tagging > "Use background tagging".  That is the only thing you should need to turn off.  Restart the editor and see if you can still reproduce the problem.

3f) Close the "Current Context" toolbar (this may be docked as part of your standard toolbar).

3g) Close the Class tool window.

3h) Close the Preview tool window.

3i) Close the Defs tool window.

3j) Turn off auto-complete (Document > Python Options > Auto-Complete > Enable auto-complete (uncheck).  Again, here you should only need to uncheck the master control.

3h) Does this problem happen when list-symbols or function-argument help is active?

3i) Try turning off auto-list-members (Document > Python Options > Auto-Complete > List Symbols > uncheck Auto-list members).

3j) Try turning off auto parameter information (Document > Python Options > Context Tagging > Auto-display parameter information.

3k) Try turning off mouse-over information (Document > Python Options > Context Tagging > Show information for symbol under mouse)

3l) Try turning off matching parenthesis highlighting.  (Tools > Options > Editing > General > Highlight matching blocks)

3m) Do you use the "File Tabs" toolbar?  Close it.

3n) Close the "Files" tool window.

3o) Close the "Open" tool window.

3p) Close the Annotations tool window.

3q) Close the Messages tool window.

3r) Turn off highlighting of the symbol under the cursor.  (Document > Python Options > Context Tagging > Highlight matching symbols under cursor)

3s) Close the Clipboard tool window.

3t) Turn off Symbol Coloring for Python (Document > Python Options > View > uncheck Symbol Coloring

3u) Turn off background Selective Display (Document > Python Options > View > Select Display > Do not create file outline, and uncheck both hide comments options.

3v) Turn off Auto-Save.  (Tools > Options > File Options > AutoSave)

3w) Turn off Auto-reload (Tools > Options > File Options > Auto-reload)

3x) Close the Backup History tool window.

3y) Close the Symbols tool window and the Find Symbol tool window.

3z) Close the Projects tool window.

4)  Are you working on a laptop with a touchpad?  Is it possible that your palm is creating unintentional mouse movements or clicks?

5) Do you have a cat?  Do not let your cat sleep on your keyboard or play with your mouse.  Yes, at this stage I have seriously ran out of valid suggestions for you unless you can put together a set of steps to reproduce the problem.

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2053
  • Hero Points: 98
Re: Still seeing text unselect itself
« Reply #9 on: January 29, 2018, 06:35:45 pm »
@texasaggie97:
4)  Are you working on a laptop with a touchpad?  Is it possible that your palm is creating unintentional mouse movements or clicks?

I wanted to reiterate this.  I have a notebook where I had to shut off the tap to click feature (which I really like) because the size/placement of the touchpad caused me to deselect text.

mwb1100

  • Senior Community Member
  • Posts: 143
  • Hero Points: 13
Re: Still seeing text unselect itself
« Reply #10 on: January 29, 2018, 09:14:05 pm »
I just wanted to mention that when this problem occurred to me (which was only for a short period of v22 Beta 2), it certainly had nothing to do with a touchpad since I only run on desktop machines.  My recollection is that I did do some testing to see if some inadvertent mouse movement was the culprit, but the problem seemed to occur even when I was careful to not move the mouse (though apparently I never mentioned that the forum). Here are threads where I talked about my brief encounter with it:

  - https://community.slickedit.com/index.php/topic,15602.msg59527.html#msg59527
  - https://community.slickedit.com/index.php/topic,15485.msg58954.html#msg58954

texasaggie97

  • Community Member
  • Posts: 20
  • Hero Points: 4
Re: Still seeing text unselect itself
« Reply #11 on: February 13, 2018, 03:30:50 pm »
Sorry it is taking so long to answer this but it is difficult to prove a negative and sometimes it takes a while to reproduce. I am still going through this list. If you're interested I am on step 3f.


texasaggie97

  • Community Member
  • Posts: 20
  • Hero Points: 4
Re: Still seeing text unselect itself
« Reply #12 on: February 20, 2018, 03:23:44 pm »
So after multiple days of not seeing the issue with 3f ("Current Context" toolbar) turned off, I turned it back on and am seeing it again and it has started happening again, but it took close to a day.

Should I just leave that disabled, or is there something else I can do to help track it down more?

jporkkahtc

  • Senior Community Member
  • Posts: 1496
  • Hero Points: 124
  • Text
Re: Still seeing text unselect itself
« Reply #13 on: February 20, 2018, 04:15:13 pm »
I still see it happen sometimes and I never have used the current context toolbar.
It may be related, but it isn't required.

I imagine its some weird timing issue, and things like current context make it more likely.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2332
  • Hero Points: 308
Re: Still seeing text unselect itself
« Reply #14 on: February 23, 2018, 10:50:16 pm »
Thanks for the hard work narrowing this down.  This gives me a good starting point as to what code to review.