If a title contained multi-byte UTF-8 characters, it wasn't properly
recognized due to the title being longer (in bytes) than the underline.
So, fix the title length computation to properly count the characters,
not the bytes.
Note that this fix only handles ASCII, one-byte charsets and UTF-8, it
won't help with other multi-bytes encodings. However, the whole parser
expects ASCII-compatible encoding anyway, and in most situations it
will be fed the Geany's UTF-8 buffer.
Closes#3578050.
We used to convert the tags from the file encoding to UTF-8, but since
we parse directly from our UTF-8 buffer, all tags are UTF-8, which lead
to an improper conversion.
Some users want the theme icon, some dislike the icon provided by
their theme and want the traditional Geany icon.
This makes that choice a various pref. Used a standalone global
to avoid impacting the plugin interface and CommandLineOptions
and GeanyStatus didn't make sense.
If the cursor was inside one of the comment's delimiters, the code used
to look for another delimiter, leading to removing previous comment's
start. Moreover, the code assumed the delimiter will always be found,
leading to improper deletions if a delimiter could not be found (either
because of the above problem or because the comment wasn't terminated).
Also, the code used document_find_text() which, if the searched text
cannot be found on the requested direction, either wraps or asks the
user whether to wrap. Wrapping is wrong if there is more than one
single comment in the file, and the dialog is confusing for the use
since she didn't ask for it.
So, rework the code for it to correctly find the delimiters, and not
to wrap search or ask the user. It is also simpler by reusing some
already existing code.
The implementation drops the non-selection code paths and simply makes
sure both caret and anchor are placed at the same position if there
was no selection. This avoids having two completely different code
paths for things that are very similar -- and alternative code paths
were buggy.
Closes#3576431.
GTK uses a signed page_nr parameter to callback draw_page despite
describing it as 0 based, cast it to unsigned for comparisons to
array len which is also unsigned.
This makes the "wordchars" setting from filetypes.common and each
specific filetype override filetype.common's "whitespace_chars"
setting, rather than it overriding filetype-specific "wordchars".
This makes the it easy to chose filetype-specific "wordchars", where
before user had not only to update this setting, but also the
filetype.common "whitespace_chars" setting if it listed one or more of
the new characters for the change to actually have an effect -- and
changing "whitespace_chars" for every filetype.
Closes#3429368.
If we generated methods, properties or class children tags for a
variable, generate a class tag for the variable itself so the children
aren't orphaned.
If a property value had more than one token, the parser choked on it
and failed to parse further properties of the object. Fix that by
properly skipping the property's value. If that value is a sub-object,
parse it recursively.
Closes#3470609.
If an `if` haven't had braces, the code used to check itself for an
`else` after it, eating the next token if it wasn't actually an `else`.
So, drop the check for the else altogether since parseLine() handles
`else`s by calling parseIf() anyway.
This fixes constructs like:
if (foo)
bar();
function baz() {
// ...
}
Closes#3568542.
This makes `Foo.bar = function()` properly report a function tag "bar"
with scope "Foo" rather than a function tag "Foo.bar" with no scope.
Part of #3570192.
There is no need to set the token position information in the loop
searching for the initial token character, simply do that when we
finally found the token start.
The external declaration of "File" in read.h (defined in read.c) was
improperly tagged as "const" for it not to be modifiable outside of
read.c. Although it is good to protect this global variable against
improper modification, the use of "const" here makes it perfectly valid
for the compiler to assume that the fields in this structure never
changes during runtime, thus allowing it to do optimizations on this
assumption. However, this assumption is wrong because this structure
actually gets modified by many read.c's functions, and thus possibly
lead to improper and unexpected behavior if the compiler sees a window
for optimizing fields access.
Moreover, protecting "File" as it was with the "const" type qualifier
required a hack to be able to include read.h in read.c since "const"
and non-"const" declarations conflicts.
Actually, at least the JavaScript parser did suffer of the issue,
because it calls getSourceLineNumber() macro (expanding to a direct
"File" member access) several times in one single function, making it
easy for the compilers to cache the value as an optimization. Both GCC
and CLang showed this behavior with optimization enabled. As a result,
the line numbers of JavaScript tags were often incorrect.
The SIGTERM handler called the standard exit callback which uses
functions that are illegal in signal handlers. Commented out as
a prelude to full removal if no use case can be made.
Geany performance suffered with a lot of error underlining visible.
Matthew Brush developed an improved implementation that was accepted
into Scintilla, this selects that implementation.
Finding the current function now better handles the case the current
line is after a function but outside its scope, and many other issues
the scope reporting had.
The code assumed that if both old and new fold levels were above the
minimal function fold level the function couldn't have been changed,
which is wrong if a function can appear both inside and outside another
fold level (e.g. inside or outside a class).
This makes symbols_get_current_function() more accurate by using TM
data even on a modified file if realtime tag parsing is enabled, thus
if the data has reasonable chances to be correct.