refactor(desktop): organize lib modules by domain
This commit is contained in:
1 parent
90f0594e93
commit
7e7c4944e9
700 files changed
+1292
-1264
No files matched your search
@@ -0,0 +1,26 @@
|
||||
export interface SqlSingleQuoteCaretOptions {
|
||||
previousValue: string;
|
||||
nextValue: string;
|
||||
selectionStart: number | null | undefined;
|
||||
}
|
||||
|
||||
export function insertedSqlSingleQuoteAtCaret(options: SqlSingleQuoteCaretOptions): boolean {
|
||||
const { previousValue, nextValue, selectionStart } = options;
|
||||
if (typeof selectionStart !== "number" || selectionStart < 1) return false;
|
||||
if (nextValue.charAt(selectionStart - 1) !== "'") return false;
|
||||
return nextValue.slice(0, selectionStart - 1) + nextValue.slice(selectionStart) === previousValue;
|
||||
}
|
||||
|
||||
export function caretPositionInsideInsertedSqlSingleQuotes(options: SqlSingleQuoteCaretOptions): number | null {
|
||||
const { previousValue, nextValue, selectionStart } = options;
|
||||
if (typeof selectionStart !== "number" || selectionStart < 2) return null;
|
||||
if (nextValue.slice(selectionStart - 2, selectionStart) !== "''") return null;
|
||||
|
||||
const singleQuoteInsertPrevious = nextValue.slice(0, selectionStart - 1) + nextValue.slice(selectionStart);
|
||||
if (singleQuoteInsertPrevious === previousValue) return selectionStart - 1;
|
||||
|
||||
const pairInsertPrevious = nextValue.slice(0, selectionStart - 2) + nextValue.slice(selectionStart);
|
||||
if (pairInsertPrevious === previousValue) return selectionStart - 1;
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in new issue
Block a user