summaryrefslogtreecommitdiff
path: root/src/xfaces.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2021-11-21 09:52:43 +0200
committerEli Zaretskii <eliz@gnu.org>2021-11-21 09:52:43 +0200
commitf2730520ce3159704801e7cd459e2971c191c5a3 (patch)
tree68282ba521189f93e850ec7b9a25d28e8264c5a2 /src/xfaces.c
parentf0507192826070ca0070c0c5ce4ac80c8b32313d (diff)
downloademacs-f2730520ce3159704801e7cd459e2971c191c5a3.tar.gz
Improve the fix for bug#51864
* src/xfaces.c (face_at_buffer_position): Call FACE_FROM_ID_OR_NULL just once. (face_at_string_position): Make sure we have a usable base face.
Diffstat (limited to 'src/xfaces.c')
-rw-r--r--src/xfaces.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index fec6b2654b1..174a1ca47c9 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -4841,7 +4841,7 @@ lookup_named_face (struct window *w, struct frame *f,
/* Return the display face-id of the basic face whose canonical face-id
is FACE_ID. The return value will usually simply be FACE_ID, unless that
- basic face has bee remapped via Vface_remapping_alist. This function is
+ basic face has been remapped via Vface_remapping_alist. This function is
conservative: if something goes wrong, it will simply return FACE_ID
rather than signal an error. Window W, if non-NULL, is used to filter
face specifications for remapping. */
@@ -6372,20 +6372,16 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
int face_id;
if (base_face_id >= 0)
- {
- face_id = base_face_id;
- /* Make sure the base face ID is usable: if someone freed the
- cached faces since we've looked up the base face, we need
- to look it up again. */
- if (!FACE_FROM_ID_OR_NULL (f, face_id))
- face_id = lookup_basic_face (w, f, DEFAULT_FACE_ID);
- }
+ face_id = base_face_id;
else if (NILP (Vface_remapping_alist))
face_id = DEFAULT_FACE_ID;
else
face_id = lookup_basic_face (w, f, DEFAULT_FACE_ID);
default_face = FACE_FROM_ID_OR_NULL (f, face_id);
+ /* Make sure the default face ID is usable: if someone freed the
+ cached faces since we've looked up these faces, we need to look
+ them up again. */
if (!default_face)
default_face = FACE_FROM_ID (f,
lookup_basic_face (w, f, DEFAULT_FACE_ID));
@@ -6573,7 +6569,9 @@ face_at_string_position (struct window *w, Lisp_Object string,
else
*endptr = -1;
- base_face = FACE_FROM_ID (f, base_face_id);
+ base_face = FACE_FROM_ID_OR_NULL (f, base_face_id);
+ if (!base_face)
+ base_face = FACE_FROM_ID (f, lookup_basic_face (w, f, DEFAULT_FACE_ID));
/* Optimize the default case that there is no face property. */
if (NILP (prop)