SlickEdit Community

SlickEdit Product Discussion => SlickEdit® => Topic started by: texasaggie97 on January 23, 2018, 08:20:34 pm

Title: Still seeing text unselect itself
Post by: texasaggie97 on January 23, 2018, 08:20:34 pm
I am still seeing the issue reported in the beta (https://community.slickedit.com/index.php/topic,15602.msg59498.html#msg59498).

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.
Title: Re: Still seeing text unselect itself
Post by: Graeme 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?
Title: Re: Still seeing text unselect itself
Post by: texasaggie97 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)
Title: Re: Still seeing text unselect itself
Post by: Graeme 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? 
Title: Re: Still seeing text unselect itself
Post by: Graeme 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;
}

Title: Re: Still seeing text unselect itself
Post by: Clark 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();
}
Title: Re: Still seeing text unselect itself
Post by: Graeme 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.)


Title: Re: Still seeing text unselect itself
Post by: Graeme on January 27, 2018, 10:55:04 pm
I am still seeing the issue reported in the beta (https://community.slickedit.com/index.php/topic,15602.msg59498.html#msg59498).

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();
}

Title: Re: Still seeing text unselect itself
Post by: Dennis 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.
Title: Re: Still seeing text unselect itself
Post by: Dan 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.
Title: Re: Still seeing text unselect itself
Post by: mwb1100 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
Title: Re: Still seeing text unselect itself
Post by: texasaggie97 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.

Title: Re: Still seeing text unselect itself
Post by: texasaggie97 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?
Title: Re: Still seeing text unselect itself
Post by: jporkkahtc 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.
Title: Re: Still seeing text unselect itself
Post by: Dennis 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.
Title: Re: Still seeing text unselect itself
Post by: Graeme on February 24, 2018, 06:38:38 am
Thanks for the hard work narrowing this down.  This gives me a good starting point as to what code to review.
Won't you be looking for a needle in a haystack?  I wonder whether you could send a debug build to the guy who can reproduce it easily, that had some kind of back tracking built into it so when a selection disappears when it shouldn't, you can capture some data that might tell you the cause.  Or maybe he could ship his computer to you...

Title: Re: Still seeing text unselect itself
Post by: Dennis on February 26, 2018, 03:00:47 pm
If the Current Context toolbar is truly the problem, then it's more of a needle in a small square bale.
Title: Re: Still seeing text unselect itself
Post by: Exolon on March 01, 2018, 10:08:32 am
I see this behavior, too, and I did a screen recording (attached).

I had the search mini window open with a search keyword matching the current line (yellow marking). Then I edited the comment above the matching line and then marked the line below the comment. As as a result, the line unselects itself. After pressing undo the selection within the comment unselects itself, too.

If I close the search mini window, the unselect is not happening.

Emulation: CUA
OS Version: Ubuntu 16.04.3 LTS
Processor Architecture: x86_64
Language: . (Bourne Shell)
Encoding: Automatic

Kind regards

Exo
Title: Re: Still seeing text unselect itself
Post by: Lee on March 01, 2018, 02:00:35 pm
I can definitely reproduce the issue where text is deselected when Mini-Find is active and highlighting matches.  I will file a defect and investigate.  I can't verify if it is the same issue for other reports in this thread, but could be related.
Title: Re: Still seeing text unselect itself
Post by: jporkkahtc on September 04, 2018, 04:37:25 pm
Still happens in V23 Beta 3.
Is there some extra debugging we can do during beta to track this down?
Title: Re: Still seeing text unselect itself
Post by: Lee on September 04, 2018, 05:54:07 pm
A fix was checked in to handle the case with Mini-Find highlighting removing selections.  That was the only reproducible case we had at the time.  We'll need to start over, do you think it is related to Mini-Find or Tool Find or is searching not even related to what you are seeing?
Title: Re: Still seeing text unselect itself
Post by: jporkkahtc on September 04, 2018, 06:06:55 pm
Not related to mini find as I don't use that, nor do I use the find tool bar.
Title: Re: Still seeing text unselect itself
Post by: Exolon on September 05, 2018, 08:13:45 am
I have strange selection behavior in 2018 Beta 3, too.

If I select a region with the mouse and switch to another window (e.g. terminal), the selection changes to something completely different.

Please see screen recording attached.

OS: Ubuntu 16.04.5 LTS
Processor Architecture: x86_64
Title: Re: Still seeing text unselect itself
Post by: Clark on September 05, 2018, 09:32:08 pm
I have strange selection behavior in 2018 Beta 3, too.

If I select a region with the mouse and switch to another window (e.g. terminal), the selection changes to something completely different.

Please see screen recording attached.

OS: Ubuntu 16.04.5 LTS
Processor Architecture: x86_64

I can't seem to reproduce this. However, I can't tell what you're clicking on. I tried clicking on a Terminal window like you say in your explanation. Does this reproduce for you with a default config (vs +new -sc /tmp/newconfigdir).
Title: Re: Still seeing text unselect itself
Post by: Exolon on September 06, 2018, 05:46:36 am
Yes, it is reproducible with a fresh VS 2018 Beta 3 configuration.
It does not matter what I'm clicking (e.g. desktop, terminal, browser, etc.) as long I click on the right side of my VS window. It does not happen if I click on the left side of SlickEdit.
The Problem is not reproducible if I turn off the minimap.
Title: Re: Still seeing text unselect itself
Post by: Clark on September 06, 2018, 01:00:31 pm
Are you clicking in the minimap window or to the right of the minimap window (shell window frame)?
Title: Re: Still seeing text unselect itself
Post by: Exolon on September 06, 2018, 01:19:31 pm
No, I'm clicking on the desktop or into a terminal on the right, outside of the SE window.
Title: Re: Still seeing text unselect itself
Post by: Clark on September 06, 2018, 03:51:07 pm
Got it to happen now. Not sure why it wouldn't repro before.
Title: Re: Still seeing text unselect itself
Post by: Clark on September 06, 2018, 04:20:02 pm
Fixed in beta 4