Skip to content

Commit

Permalink
refactor: Rename getConfigProperty -> getMemoConfigProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
svsool committed Sep 19, 2020
1 parent 67ae66c commit 6ebf5cf
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/features/BacklinksTreeDataProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getWorkspaceFolder,
toPlainObject,
updateMemoConfigProperty,
getConfigProperty,
getMemoConfigProperty,
} from '../test/testUtils';

const getChildren = async () => {
Expand Down Expand Up @@ -387,7 +387,7 @@ describe('BacklinksTreeDataProvider', () => {

await window.showTextDocument(doc);

expect(getConfigProperty('backlinksPanel.collapseParentItems', null)).toBe(false);
expect(getMemoConfigProperty('backlinksPanel.collapseParentItems', null)).toBe(false);

expect((await getChildren()).every((child) => child.collapsibleState === 2)).toBe(true);
});
Expand Down
4 changes: 2 additions & 2 deletions src/features/BacklinksTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getWorkspaceFolder,
trimSlashes,
sortPaths,
getConfigProperty,
getMemoConfigProperty,
} from '../utils';
import { FoundRefT } from '../types';

Expand Down Expand Up @@ -58,7 +58,7 @@ export default class BacklinksTreeDataProvider implements vscode.TreeDataProvide
return [];
}

const collapsibleState = getConfigProperty('backlinksPanel.collapseParentItems', false)
const collapsibleState = getMemoConfigProperty('backlinksPanel.collapseParentItems', false)
? vscode.TreeItemCollapsibleState.Collapsed
: vscode.TreeItemCollapsibleState.Expanded;

Expand Down
4 changes: 2 additions & 2 deletions src/features/ReferenceHoverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
containsUnknownExt,
containsOtherKnownExts,
getWorkspaceCache,
getConfigProperty,
getMemoConfigProperty,
getReferenceAtPosition,
isUncPath,
findUriByRef,
Expand Down Expand Up @@ -39,7 +39,7 @@ export default class ReferenceHoverProvider implements vscode.HoverProvider {

if (foundUri && fs.existsSync(foundUri.fsPath)) {
const imageMaxHeight = Math.max(
getConfigProperty('linksOnHoverPreview.imageMaxHeight', 200),
getMemoConfigProperty('linksOnHoverPreview.imageMaxHeight', 200),
10,
);
const getContent = () => {
Expand Down
4 changes: 2 additions & 2 deletions src/test/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ const {
getImgUrlForMarkdownPreview,
getFileUrlForMarkdownPreview,
escapeForRegExp,
getConfigProperty,
getMemoConfigProperty,
} = utils;

export {
getConfigProperty,
getMemoConfigProperty,
getWorkspaceFolder,
getImgUrlForMarkdownPreview,
getFileUrlForMarkdownPreview,
Expand Down
8 changes: 4 additions & 4 deletions src/utils/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
normalizeSlashes,
getWorkspaceFolder,
getWorkspaceCache,
getConfigProperty,
getMemoConfigProperty,
matchAll,
cacheWorkspace,
cacheUris,
Expand Down Expand Up @@ -819,13 +819,13 @@ describe('getWorkspaceFolder()', () => {
});
});

describe('getConfigProperty()', () => {
describe('getMemoConfigProperty()', () => {
it('should return config property', () => {
expect(getConfigProperty('linksOnHoverPreview.imageMaxHeight', null)).toBe('200');
expect(getMemoConfigProperty('linksOnHoverPreview.imageMaxHeight', null)).toBe('200');
});

it('should return default property on getting unknown config property', () => {
expect(getConfigProperty('unknownProperty', 'default')).toBe('default');
expect(getMemoConfigProperty('unknownProperty', 'default')).toBe('default');
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export const cleanWorkspaceCache = () => {
export const getWorkspaceFolder = (): string | undefined =>
vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders[0].uri.fsPath;

export function getConfigProperty<T>(property: string, fallback: T): T {
export function getMemoConfigProperty<T>(property: string, fallback: T): T {
return vscode.workspace.getConfiguration().get(`memo.${property}`, fallback);
}

Expand Down

0 comments on commit 6ebf5cf

Please sign in to comment.