lintalist icon indicating copy to clipboard operation
lintalist copied to clipboard

Shorthand: use Hotstring() to replace Loop + Input

Open lintalist opened this issue 5 years ago • 16 comments

Currently Lintalist uses a "faux" hotstring function by using a Loop + Input.

This should be replaced by the new native https://autohotkey.com/docs/commands/Hotstring.htm function for better reliability.

  • https://github.com/lintalist/lintalist/issues/127#issuecomment-496279719
  • #143

lintalist avatar Nov 20 '19 17:11 lintalist

Is this related to performance contrast between hotstrings and shorthand? Will briefs be faster now?

beefeater7 avatar Jan 15 '20 00:01 beefeater7

Yes, using Hotstrings() should improve the overall reliability and possibly offer some speed improvements.

lintalist avatar Jan 15 '20 17:01 lintalist

A (experimental!) development branch is available here: https://github.com/lintalist/lintalist/tree/dev-hotstrings

If you try it out please make sure you have a backup of your bundles, they may end up corrupted (shouldn't happen but if you have backups nothing is lost)

lintalist avatar May 07 '20 17:05 lintalist

I finally got around to trying this, and the performance markedly improved! Very nice.

beefeater7 avatar Jun 19 '20 00:06 beefeater7

I've tested the experimental fix, but it happend again. However, it took a good amount of time, compared to the normal 5-30minutes (2-3 hotstrings).

Are there any way to check why it's not listening, like it should? (Debug-log, specific commands, command-lookup, and so on...)

exetico avatar Oct 20 '20 09:10 exetico

Nope, no debugging available, I tried to add something in the past but as it jumps around all over the script it isn't really feasible (would require a "log" command after nearly every command to pin point a problem). This experiment was a first attempt, the entire shorthand/hotkey routine needs to be redone which would hopefull fix it, if it doesn't it should at least make it a bit easier to bug track where it "stops" :(

lintalist avatar Oct 20 '20 16:10 lintalist

Update: After moving the application to another locations, it's more stable with the Hotstring(), so something must be working - And I can't tell if it's a combination, or if it isolated to a single thing. I'll continue to use the experimental version.

exetico avatar Oct 27 '20 14:10 exetico

Hi,

There's something broken in the latest dev-hotsrings branch. Going from shorthand to key-shotcut works every time, but going from key-shotcut to shorthand doesn't work properly. It's failing to execute the shorthand properly the first time.

Example:

  1. "test" > Shorthand works
  2. Ctrl+Alt+b > Key-shortcut works
  3. "test" > Shorthand doesnt execute properly. But the shorthand text itself, are removed from the editor where I entered "test".
  4. "test" again > Now it's working again.

Grap the latest dev-hotstrings, and use the following bundle:

BundleFormat: 1
Name: Default
Description: Default bundle for Lintalist
Author: Lintalist
TitleMatch:
Patterns:
- LLPart1: This is Snippet Part 1, refer to documentation for further info.
  LLPart2: This is Snippet Part 2
  LLKey: 
  LLShorthand: test
  LLScript:
- LLPart1: This is Snippet Part 111, refer to documentation for further info.
  LLPart2: This is Snippet Part 222
  LLKey: ^!b
  LLShorthand: 
  LLScript:

Or grap my file: lintalist-dev-hotstrings.zip

I really hope you're able to fix this, @lintalist . I'm not that good in the AHK-codebase, so I can't spot what's breaking.

Here's a GIF: lintalist-bug

The "Hotstring()" method are way more stable, so it's not an option to go back to the old loop-method. 🦄🌞 🌈

exetico avatar Jun 23 '21 10:06 exetico

I'm still thinking about it :) one caveat I can't put my finger on is how to deal with duplicate hotstrings that are available in two or more bundles. e.g. /b in HTML and CSS which (titlematch for both: html,css) which at the moment shows a menu "which one to use" - with hotstrings I haven't thought of a way to do that - or I would simply have to accept you can only have one hotstring (it would load only the first one it finds so either always HTML or CCS in the case, would depend on which bundle would be loaded first).

AutoHotkey 2 (beta) is around the corner, so I'm tempted to re-write Lintalist in AutoHotkey v2 getting rid of all the spaghetti code and "dirty hacks" which would make it easier to maintain.

lintalist avatar Jun 23 '21 16:06 lintalist

@lintalist - That's fair. But can't we fix the issue, which I just mentioned? I thought that was easy to fix 😊? That would be SO NICE 😅...

exetico avatar Jun 23 '21 16:06 exetico

Try this (experimental so backup everything) lintalist.zip

lintalist avatar Jun 23 '21 19:06 lintalist

Looks OK to me :-) https://www.diffchecker.com/soSDCQF9

I'll give it a try!

Update: Looks OK in my end. Can OutputDebug be removed? I guess so... So I've just removed these lines.

lintalist.zip

exetico avatar Jun 24 '21 06:06 exetico

Do report back if

  • it works flawlessly :)
  • the wrong snippet is pasted at some point, especially if you can reproduce it
  • if snippets go missing or get duplicated somehow

Edit: I think you can still make it trip up after cancelling a plugin (choice, filelist)

lintalist avatar Jun 24 '21 16:06 lintalist

Still no issues seen in the latest fix 👍

exetico avatar Jul 02 '21 17:07 exetico

Hi Lintalist.

Here's another follow up. Everything are working as expected, and we've not seen other issues/bugs in relation to this change. So I guess it's safe to make the chage in the main release.

exetico avatar Jul 21 '21 10:07 exetico

It stopped working two times in a row today, I don't know why though. There is a certain chain of events that sets or doesn't clear a variable that is used later so it just stops and only a restart fixes it. It can work for days on end and today I did something and it stopped, but I can't pin point it to what "it" is yet. Very annoying.

lintalist avatar Jul 23 '21 17:07 lintalist