Incremental SciTE autocompletion

844 views
Skip to first unread message

Sergey Kishchenko

unread,
Dec 9, 2008, 12:25:31 PM12/9/08
to scite-interest
Hi.

SciTE is one of my favourite editors. It have many killer-features,
but I really miss one - Incremental SciTE autocompletion.

Now if you set "autocompleteword.automatic=1" the completion list will
popup automatically but only in case when you have only one completion
variant.

You can hit Ctrl+Enter and all possible choices will popup. I think,
SciTE really misses ability to modify the completion variants list
while typing, incrementally, without hitting ctrl+enter.

I created a patch, that adds this feature to SciTE. Feature can be
turned on by "autocompleteword.incremental=1" property. My solution is
very naive and I want to know, is there any alternative?

Patch:

Index: src/SciTEBase.cxx
===================================================================
RCS file: /cvsroot/scintilla/scite/src/SciTEBase.cxx,v
retrieving revision 1.699
diff -u -p -r1.699 SciTEBase.cxx
--- src/SciTEBase.cxx 27 Nov 2008 22:45:19 -0000 1.699
+++ src/SciTEBase.cxx 9 Dec 2008 13:45:58 -0000
@@ -3084,7 +3084,7 @@ void SciTEBase::CharAdded(char ch) {
StartAutoComplete();
}
} else if (autoCCausedByOnlyOne) {
- StartAutoCompleteWord(true);
+ StartAutoCompleteWord(!props.GetInt
("autocompleteword.incremental"));
}
} else if (HandleXml(ch)) {
// Handled in the routine
@@ -3101,7 +3101,7 @@ void SciTEBase::CharAdded(char ch) {
if (autoCompleteStartCharacters.contains(ch)) {
StartAutoComplete();
} else if (props.GetInt("autocompleteword.automatic") &&
wordCharacters.contains(ch)) {
- StartAutoCompleteWord(true);
+ StartAutoCompleteWord(!props.GetInt
("autocompleteword.incremental"));
autoCCausedByOnlyOne = SendEditor(SCI_AUTOCACTIVE);
}
}

Frank Wunderlich

unread,
Dec 9, 2008, 7:32:33 PM12/9/08
to scite-i...@googlegroups.com
Hi Sergey,
nice patch, i've missed this like you.
but there are some issues with it,
- the list should be also triggered on backspace to increase the list again.
- the list should also be hidden if there is no word anymore.
- the list should be decremented when shown without
autocompleteword.automatic=1 (triggered by ctrl+enter)

if this is patched, maybe neil accept this patch.


Sergey Kishchenko

unread,
Dec 10, 2008, 9:53:42 AM12/10/08
to scite-interest
Yeah, I foreget about backspace :) I created patches for scintilla and
scite (http://groups.google.com/group/scite-interest/web/
incremental_autocompletion.tar.gz). They fix issues from your list.

Sergey Kishchenko

unread,
Dec 11, 2008, 4:30:23 AM12/11/08
to scite-interest
For everyone who wants to see, how this feature work, but don't want
to apply the patch I created the screencast with presentation of
feature. You can find it here: http://tilarids.blogspot.com/2008/12/scite-incremental-autocompletion.html

Luis Rascão

unread,
Dec 11, 2008, 6:17:58 AM12/11/08
to scite-interest
Great feature! Nice work!
One note though, i had to set the following properties to get it to
work like in your video:

autocompleteword.automatic=1
autocomplete.choose.single=0
autocompleteword.incremental=1


On Dec 11, 9:30 am, Sergey Kishchenko <void...@gmail.com> wrote:
> For everyone who wants to see, how this feature work, but don't want
> to apply the patch I created the screencast with presentation of
> feature. You can find it here:http://tilarids.blogspot.com/2008/12/scite-incremental-autocompletion...

Sergey Kishchenko

unread,
Dec 11, 2008, 10:31:43 AM12/11/08
to scite-interest
Yes, i always used

autocompleteword.automatic=1
autocomplete.choose.single=0

so I forgot to say about that.
Frank Wunderlich noticed some bug in implementation, this patch should
fix it http://groups.google.com/group/scite-interest/web/incremental_autocompletion_v2.tar.gz

Frank

unread,
Dec 11, 2008, 10:54:04 AM12/11/08
to scite-interest
Scite-Ru-Patch is listed there:
http://code.google.com/p/scite-ru/issues/detail?id=129

regards Frank

Neil Hodgson

unread,
Dec 11, 2008, 8:37:17 PM12/11/08
to scite-i...@googlegroups.com
The test at the top of StartAutoCompleteWord is strange: its
effect is to remove the autocompletion if you backspace to the start
of the line. Perhaps it is supposed to remove the autocompletion if
you backspace to the starting point.
The SCN_AUTOCUPDATED handler will interfere with other uses of
autocompletion such as Complete Symbol and Lua scripts.
Unless SCN_AUTOCUPDATED is supposed to be fired in more cases then
it is poorly named as it fires only when a character is deleted.
The relationship between the autocompleteword properties is messy:
perhaps this should be mode 2 of autocompleteword.automatic rather
than a separate property.
This will need documentation patches to be accepted.

Neil

Sergey Kishchenko

unread,
Dec 12, 2008, 6:02:23 AM12/12/08
to scite-interest
On 12 дек, 03:37, "Neil Hodgson" <nyamaton...@gmail.com> wrote:
>    The test at the top of  StartAutoCompleteWord is strange: its
> effect is to remove the autocompletion if you backspace to the start
> of the line. Perhaps it is supposed to remove the autocompletion if
> you backspace to the starting point.
In original implementation autocompletion window is removed when you
backspace to the postion _before_ starting point. It is ok when you
are in the middle of the line, but it is annoying, when you need to
backspace to previous line to hide autocompletion. Test you mentioned
is aimed to fix this problem. It is unrelated to incremental
autocompletion. Probably, it should be discussed in different
thread.
>    The SCN_AUTOCUPDATED handler will interfere with other uses of
> autocompletion such as Complete Symbol and Lua scripts.
> Unless SCN_AUTOCUPDATED is supposed to be fired in more cases then
> it is poorly named as it fires only when a character is deleted.
Is there any test cases for me to test these features with my patch?
Probably, rename is the only thing that is needed.
>    The relationship between the autocompleteword properties is messy:
> perhaps this should be mode 2 of autocompleteword.automatic rather
> than a separate property.
>    This will need documentation patches to be accepted.
>
>    Neil
Agreed. I'll work on it.

Sergey Kishchenko

unread,
Dec 12, 2008, 11:06:57 AM12/12/08
to scite-interest
I thought about this feature and I think it can be improved. I propose
these improvements:
1. Automatic Symbol Completion. It'll work the same as the existing
`autocompleteword.automatic=1` but for symbols (maybe
autocomplete.automatic=1 should switch this feature on)
2. Automatic Incremental Symbol Completion(autocomplete.automatic=2 ?)
---and far far future planning---
3. Mixed Automatic Completion and Mixed Incremental Completion(words
and symbols are mixed together)

I already improved my patch to support Automatic Incremental Symbol
Completion. I must know if anyone needs "Automatic Symbol Completion"
or Mixed Completion to proceed. Also I'll be glad to hear advices
about how all these things should be implemented.

Frank Wunderlich

unread,
Dec 12, 2008, 12:08:08 PM12/12/08
to scite-i...@googlegroups.com
Sergey Kishchenko, 12.12.2008 17:06:

> 3. Mixed Automatic Completion and Mixed Incremental Completion(words
> and symbols are mixed together)
>
sciteRu has the ability to show words and symbols from API-Files
together in the autocomplete list without an extra property. maybe you
can look there for the neccessary code. imho neil rejected the patch, so
it's not available in the original scite-version.

regards Frank

Neil Hodgson

unread,
Dec 12, 2008, 6:36:42 PM12/12/08
to scite-i...@googlegroups.com
Sergey Kishchenko:

> Test you mentioned
> is aimed to fix this problem. It is unrelated to incremental
> autocompletion. Probably, it should be discussed in different
> thread.

OK. If you want the autocompletion to go away, press Escape.

>> The SCN_AUTOCUPDATED handler will interfere with other uses of
>> autocompletion such as Complete Symbol and Lua scripts.
>> Unless SCN_AUTOCUPDATED is supposed to be fired in more cases then
>> it is poorly named as it fires only when a character is deleted.
> Is there any test cases for me to test these features with my patch?
> Probably, rename is the only thing that is needed.

Using an API file, press Ctrl+I to display API symbols and type
some initial letters. Press backspace and the API symbols go away to
be replaced with words from the current file.

Neil

Neil Hodgson

unread,
Dec 12, 2008, 6:43:00 PM12/12/08
to scite-i...@googlegroups.com
Sergey Kishchenko:

> I thought about this feature and I think it can be improved. I propose
> these improvements:
> 1. Automatic Symbol Completion. It'll work the same as the existing
> `autocompleteword.automatic=1` but for symbols (maybe
> autocomplete.automatic=1 should switch this feature on)

Then you have to define which takes precedence.

> 2. Automatic Incremental Symbol Completion(autocomplete.automatic=2 ?)
> ---and far far future planning---
> 3. Mixed Automatic Completion and Mixed Incremental Completion(words
> and symbols are mixed together)

For my own use, I don't want the two sources of words mixed by default.

Neil

Sergey Kishchenko

unread,
Dec 22, 2008, 6:58:19 AM12/22/08
to scite-interest
New version can be found here :
http://groups.google.com/group/scite-interest/web/incremental_autocompletion_v3.tar.gz
It consists of
1. Incremental word autocompletion(autocompleteword.automatic=1 and
autocompleteword.automatic=2)
2. Incremental symbol autocompletion (autocomplete.automatic=1 and
autocomplete.automatic=2)
3. Docs patch
4. gtk makefile patches (I use `make DEBUG=1 TRACE=1` for tracing)
5. 'Annoying extra backspace to cancel autocompletion' fixed

I found interesting behaviour. If I use api file, then Word
Autocompletion feature doesn't work properly. For example, I have
'some some2 some3' in my file. If I press Ctrl+Enter, popup window
will contain only 'some' word, but it should contain also the 'some2'
and 'some3' words. This bug reproduces in cvs version. I'll try to
find related issue.

Neil Hodgson

unread,
Jan 2, 2009, 2:20:08 AM1/2/09
to scite-i...@googlegroups.com
Sergey Kishchenko:

> New version can be found here :
> http://groups.google.com/group/scite-interest/web/incremental_autocompletion_v3.tar.gz
> It consists of
> 1. Incremental word autocompletion(autocompleteword.automatic=1 and
> autocompleteword.automatic=2)
> 2. Incremental symbol autocompletion (autocomplete.automatic=1 and
> autocomplete.automatic=2)
> 3. Docs patch

Looks like it still doesn't cope with scripted autocompletion lists.

To test with scripted autocompletion you can add to your startup
script something like:

function ShowList()
editor:AutoCShow(1, "abc bbb def")
end

Then in user properties:

command.name.5.*=ShowList
command.5.*=ShowList()
command.subsystem.5.*=3

Then restart SciTE.

> 4. gtk makefile patches (I use `make DEBUG=1 TRACE=1` for tracing)

Don't want this.

> 5. 'Annoying extra backspace to cancel autocompletion' fixed

When I deliberately start an autocompletion I don't want it to
disappear just because I have undone the typing.

> I found interesting behaviour. If I use api file, then Word
> Autocompletion feature doesn't work properly. For example, I have
> 'some some2 some3' in my file. If I press Ctrl+Enter, popup window
> will contain only 'some' word, but it should contain also the 'some2'
> and 'some3' words. This bug reproduces in cvs version. I'll try to
> find related issue.

This happens without an API file as well. The set of characters allowed for
the list of words comes from the word.characters.<filepattern> setting
which doesn't include digits. The documentation says that this is supposed
to default to including digits but it doesn't. Probably best to change
default to match documentation.

Neil

Sergey Kishchenko

unread,
Jan 8, 2009, 10:48:07 AM1/8/09
to scite-interest
On 2 янв, 09:20, "Neil Hodgson" <nyamaton...@gmail.com> wrote:
>    Looks like it still doesn't cope with scripted autocompletion lists.
>
>    To test with scripted autocompletion you can add to your startup
> script something like:
>
> function ShowList()
>         editor:AutoCShow(1, "abc bbb def")
> end
>
>    Then in user properties:
>
> command.name.5.*=ShowList
> command.5.*=ShowList()
> command.subsystem.5.*=3
>
>    Then restart SciTE.

I tried this feature and I didn't find any bugs related to the patch.
Patched SciTE acts the same as the original SciTE. What kind of
problems with scripted autocompletion do you have?

> > 4. gtk makefile patches (I use `make DEBUG=1 TRACE=1` for tracing)
>
>    Don't want this.
Ok.

> > 5. 'Annoying extra backspace to cancel autocompletion' fixed
>
>    When I deliberately start an autocompletion I don't want it to
> disappear just because I have undone the typing.
Ok.

>    This happens without an API file as well. The set of characters allowed for
> the list of words comes from the word.characters.<filepattern> setting
> which doesn't include digits. The documentation says that this is supposed
> to default to including digits but it doesn't. Probably best to change
> default to match documentation.

I'll comment in the following bug-tracker's thread.

Neil Hodgson

unread,
Jan 8, 2009, 5:10:59 PM1/8/09
to scite-i...@googlegroups.com
Sergey Kishchenko:

> I tried this feature and I didn't find any bugs related to the patch.
> Patched SciTE acts the same as the original SciTE. What kind of
> problems with scripted autocompletion do you have?

There is a bit of global state associated with the 'only one' mode.
If you cancel (with Esc) from an 'only one' popup, I think that state
persists so when you use backspace on the scripted autocompletion it
replaces the autocompletion with a list of similar words, just as if
it was invoked for that purpose rather than by the script. Any state
changed by entering an 'only one' popup should be cleared when it goes
away for any reason or else the code that responds to the backspace
needs to work out why the autocompletion was shown.

Neil

Reply all
Reply to author
Forward
0 new messages