Skip to content

Commit

Permalink
Merge pull request #50 from rolandbernard/devel
Browse files Browse the repository at this point in the history
Fixes and improvements
  • Loading branch information
rolandbernard committed Sep 28, 2021
2 parents 601f8dd + a3d875a commit 5401c70
Show file tree
Hide file tree
Showing 4 changed files with 305 additions and 275 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "marvin",
"version": "0.4.0",
"version": "0.4.1",
"description": "This is a keystroke launcher for Linux",
"repository": "https://github.com/rolandbernard/marvin/",
"author": "Roland Bernard",
Expand Down
12 changes: 10 additions & 2 deletions src/common/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export class Query {
readonly regex: RegExp;

escapeRegex(text: string, map?: (c: string) => string, join = '') {
return text.split('').map((ch) => {
return this.normalizeString(text.substr(0, MAX_MATCH_LENGTH))
.split('').map((ch) => {
// Escape special regex characters
if ([
'\\', '.', '*', '+', '[', ']', '(', ')', '{', '}',
Expand Down Expand Up @@ -46,6 +47,12 @@ export class Query {
}
}

normalizeString(text: string): string {
return text.normalize('NFKD')
.replace(/[\u0300-\u036F]/g, '')
.replace(/\s+/g, ' ');
}

bestMatch(text: string): string | undefined {
text = text.substr(0, MAX_MATCH_LENGTH);
let best: string | undefined;
Expand All @@ -57,7 +64,8 @@ export class Query {
return best;
}

matchText(text: string): number {
matchText(full_text: string): number {
const text = this.normalizeString(full_text.substr(0, MAX_MATCH_LENGTH));
if (text.length > 0 && this.text.length > 0) {
const best_match = this.bestMatch(text);
if (best_match) {
Expand Down
1 change: 1 addition & 0 deletions src/main/modules/updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ipcMain.on(IpcChannels.CHECK_FOR_UPDATE, async (msg) => {
ipcMain.on(IpcChannels.INSTALL_UPDATE, async () => {
if (!isDevelopment()) {
try {
await checkForUpdate();
await autoUpdater.downloadUpdate();
autoUpdater.quitAndInstall();
} catch (e) {
Expand Down
Loading

0 comments on commit 5401c70

Please sign in to comment.