annotate runtime/syntax/messages.vim @ 34416:0a458b49e1e6 v9.1.0131

patch 9.1.0131: buffer-completion may not always find all matches Commit: https://github.com/vim/vim/commit/0dc0bff000fd804c6b0778ccc4554a4e4c82c8c9 Author: Christian Brabandt <cb@256bit.org> Date: Sat Feb 24 14:12:13 2024 +0100 patch 9.1.0131: buffer-completion may not always find all matches Problem: buffer-completion code too complicated and does not always find all matches (irisjae) Solution: do not try to anchor pattern to beginning of line or directory-separator, always return all matches Note: we are considering the non-fuzzy buffer-matching here. Currently, the buffer-completion code makes 2 attempts to match a pattern against the list of available patterns. First try is to match the pattern and anchor it to either the beginning of the file name or at a directory-separator (// or \\). When a match is found, Vim returns the matching buffers and does not try to find a match anywhere within a buffer name. So if you have opened two buffers like /tmp/Foobar.c and /tmp/MyFoobar.c using `:b Foo` will only complete to the first filename, but not the second (the same happens with `getcompletion('Foo', 'buffer')`). It may make sense, that completion priorities buffer names at directory boundaries, but it inconsistent, may cause confusion why a certain buffer name is not completed when typing `:b Foo<C-D>` which returns only a single file name and then pressing Enter (to switch to that buffer), Vim will error with 'E93: More than one match for Foo'). Similar things may happen when wiping the /tmp/Foobar.c pattern and afterwards the completion starts completing other buffers. So let's simplify the code and always match the pattern anywhere in the buffer name, do not try to favor matches at directory boundaries. This is also simplifies the code a bit, we do not need to run over the list of buffers several times, but only twice. fixes #13894 closes: #14082 Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 24 Feb 2024 14:30:03 +0100
parents 5b37a0bf7e3a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
1 " Vim syntax file
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
2 " Language: /var/log/messages file
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
3 " Maintainer: Yakov Lerner <iler.ml@gmail.com>
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1125
diff changeset
4 " Latest Revision: 2008-06-29
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1125
diff changeset
5 " Changes: 2008-06-29 support for RFC3339 tuimestamps James Vega
7707
41768bcebc9b commit https://github.com/vim/vim/commit/13d5aeef56e3140a8eb8f40c7062aa1c5700f76e
Christian Brabandt <cb@256bit.org>
parents: 1668
diff changeset
6 " 2016 Jan 19: messagesDate changed by Bram
23931
5b37a0bf7e3a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 7707
diff changeset
7 " 2021 Jan 27: messagesHourRFC3339 changed from #946
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
8
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
9 if exists("b:current_syntax")
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
10 finish
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
11 endif
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
12
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
13 let s:cpo_save = &cpo
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
14 set cpo&vim
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
15
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1125
diff changeset
16 syn match messagesBegin display '^' nextgroup=messagesDate,messagesDateRFC3339
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
17
7707
41768bcebc9b commit https://github.com/vim/vim/commit/13d5aeef56e3140a8eb8f40c7062aa1c5700f76e
Christian Brabandt <cb@256bit.org>
parents: 1668
diff changeset
18 syn match messagesDate contained display '[[:lower:][:upper:]][[:lower:][:upper:]][[:lower:][:upper:]] [ 0-9]\d *'
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
19 \ nextgroup=messagesHour
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
20
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
21 syn match messagesHour contained display '\d\d:\d\d:\d\d\s*'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
22 \ nextgroup=messagesHost
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
23
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1125
diff changeset
24 syn match messagesDateRFC3339 contained display '\d\{4}-\d\d-\d\d'
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1125
diff changeset
25 \ nextgroup=messagesRFC3339T
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1125
diff changeset
26
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1125
diff changeset
27 syn match messagesRFC3339T contained display '\cT'
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1125
diff changeset
28 \ nextgroup=messagesHourRFC3339
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1125
diff changeset
29
23931
5b37a0bf7e3a Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 7707
diff changeset
30 syn match messagesHourRFC3339 contained display '\c\d\d:\d\d:\d\d\(\.\d\+\)\=\([+-]\d\d:\d\d\|Z\)\s*'
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1125
diff changeset
31 \ nextgroup=messagesHost
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1125
diff changeset
32
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
33 syn match messagesHost contained display '\S*\s*'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
34 \ nextgroup=messagesLabel
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
35
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
36 syn match messagesLabel contained display '\s*[^:]*:\s*'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
37 \ nextgroup=messagesText contains=messagesKernel,messagesPID
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
38
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
39 syn match messagesPID contained display '\[\zs\d\+\ze\]'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
40
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
41 syn match messagesKernel contained display 'kernel:'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
42
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
43
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
44 syn match messagesIP '\d\+\.\d\+\.\d\+\.\d\+'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
45
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
46 syn match messagesURL '\w\+://\S\+'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
47
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
48 syn match messagesText contained display '.*'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
49 \ contains=messagesNumber,messagesIP,messagesURL,messagesError
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
50
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
51 syn match messagesNumber contained '0x[0-9a-fA-F]*\|\[<[0-9a-f]\+>\]\|\<\d[0-9a-fA-F]*'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
52
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
53 syn match messagesError contained '\c.*\<\(FATAL\|ERROR\|ERRORS\|FAILED\|FAILURE\).*'
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
54
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
55
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
56 hi def link messagesDate Constant
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
57 hi def link messagesHour Type
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1125
diff changeset
58 hi def link messagesDateRFC3339 Constant
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1125
diff changeset
59 hi def link messagesHourRFC3339 Type
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1125
diff changeset
60 hi def link messagesRFC3339T Normal
1125
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
61 hi def link messagesHost Identifier
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
62 hi def link messagesLabel Operator
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
63 hi def link messagesPID Constant
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
64 hi def link messagesKernel Special
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
65 hi def link messagesError ErrorMsg
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
66 hi def link messagesIP Constant
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
67 hi def link messagesURL Underlined
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
68 hi def link messagesText Normal
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
69 hi def link messagesNumber Number
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
70
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
71 let b:current_syntax = "messages"
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
72
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
73 let &cpo = s:cpo_save
96cd8222a819 updated for version 7.1a
vimboss
parents:
diff changeset
74 unlet s:cpo_save