✨ Improve search term escaping and formatting in Gamemaster search functionality
This commit is contained in:
@@ -138,7 +138,10 @@ export function useGamemasterSearch(fileLines, displayLines) {
|
||||
function performSynchronousSearch() {
|
||||
const results = [];
|
||||
const searchTerm = searchQuery.value.toLowerCase();
|
||||
const escapedTerm = searchTerm.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
|
||||
const escapedTerm = searchTerm.replace(
|
||||
/[.*+?^${}()|[\]\\]/g,
|
||||
String.raw`\$&`
|
||||
);
|
||||
|
||||
try {
|
||||
// Try regex pattern first
|
||||
@@ -171,7 +174,7 @@ export function useGamemasterSearch(fileLines, displayLines) {
|
||||
/**
|
||||
* Execute search when query changes
|
||||
*/
|
||||
const executeSearch = async (query) => {
|
||||
const executeSearch = async query => {
|
||||
searchQuery.value = query;
|
||||
await performSearch();
|
||||
};
|
||||
@@ -243,7 +246,10 @@ export function useGamemasterSearch(fileLines, displayLines) {
|
||||
if (!searchQuery.value.trim()) return lineContent;
|
||||
|
||||
const searchTerm = searchQuery.value;
|
||||
const escapedTerm = searchTerm.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
|
||||
const escapedTerm = searchTerm.replace(
|
||||
/[.*+?^${}()|[\]\\]/g,
|
||||
String.raw`\$&`
|
||||
);
|
||||
const regex = new RegExp(`(${escapedTerm})`, 'gi');
|
||||
|
||||
return lineContent.replaceAll(regex, '<mark>$1</mark>');
|
||||
|
||||
Reference in New Issue
Block a user