-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desktop: Fixes #7834: Merged shorthand variants of spellcheck languages #9983
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b07903c
Desktop: Made the same spellcheck languages more specific in the titl…
HahaBill d1e3652
Merge branch 'laurent22:dev' into dev
HahaBill 9f2b42e
Fixed the build issue from GitHub Actions
HahaBill 7f2c5d4
Merge branch 'dev' of https://github.com/HahaBill/joplin-hahabill int…
HahaBill a831916
Create determineProfileDir.js
HahaBill 8a936d6
Desktop: Putting the mock back into the test file "showSpellCheckerMe…
HahaBill e934d91
Desktop: Implemented 2nd solution and modified unit test
HahaBill 12ba64f
Deleting an auto-generated file: determineProfileDir.js
HahaBill d4b6926
Desktop: More clarity on changes in "buildScriptIndexes.js"
HahaBill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/app-desktop/gui/MainScreen/commands/showSpellCheckerMenu.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { runtime } from './showSpellCheckerMenu'; | ||
import { AppState } from '../../../app.reducer'; | ||
|
||
describe('mapStateTotitle', () => { | ||
|
||
test('should return null if spellchecker.enabled is false', () => { | ||
|
||
const mockState: Partial<AppState> = { | ||
settings: { | ||
'spellChecker.enabled': false, | ||
'spellChecker.languages': ['en-GB'], | ||
}, | ||
}; | ||
const result = runtime().mapStateToTitle(mockState); | ||
expect(result).toBeNull(); | ||
}); | ||
|
||
test('should return null if spellChecker.languages is empty', () => { | ||
const mockState: Partial<AppState> = { | ||
settings: { | ||
'spellChecker.enabled': true, | ||
'spellChecker.languages': [], | ||
}, | ||
}; | ||
const result = runtime().mapStateToTitle(mockState); | ||
expect(result).toBeNull(); | ||
}); | ||
|
||
test('should return list of countryDisplayName with correct format', () => { | ||
const mockState: Partial<AppState> = { | ||
settings: { | ||
'spellChecker.enabled': true, | ||
'spellChecker.languages': ['en-GB', 'en-US', 'en-CA', 'es-ES', 'es-MX'], | ||
}, | ||
}; | ||
const result = runtime().mapStateToTitle(mockState); | ||
expect(result).toBe('en-GB, en-US, en-CA, es-ES, es-MX'); | ||
|
||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
personalizedrefrigerator marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const os_1 = require('os'); | ||
const path_utils_1 = require('./path-utils'); | ||
exports.default = (profileFromArgs, appName) => { | ||
let output = ''; | ||
if (profileFromArgs) { | ||
output = profileFromArgs; | ||
} else if (process && process.env && process.env.PORTABLE_EXECUTABLE_DIR) { | ||
output = `${process.env.PORTABLE_EXECUTABLE_DIR}/JoplinProfile`; | ||
} else { | ||
output = `${(0, os_1.homedir)()}/.config/${appName}`; | ||
} | ||
return (0, path_utils_1.toSystemSlashes)(output, 'linux'); | ||
}; | ||
// # sourceMappingURL=determineProfileDir.js.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -12,7 +12,7 @@ async function processDirectory(dir, indexFilePath = null, typeScriptType = null | |||||||||||
|
||||||||||||
const tsFiles = glob.sync('{**/*.ts,**/*.tsx}', { | ||||||||||||
cwd: dir, | ||||||||||||
}).filter(f => `${dir}/${f}` !== indexFilePath); | ||||||||||||
}).filter(f => `${dir}/${f}` !== indexFilePath && !f.endsWith('.test.ts')); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
(Optional) A brief comment might be helpful here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will do that. Thanks for sharing your implementation! |
||||||||||||
|
||||||||||||
tsFiles.sort(); | ||||||||||||
|
||||||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obviously it was previously implemented this way for a reason, and you removed that feature.
So what's your reasoning, why do you think it was implemented this way, and is the best fix really to remove it without even a discussion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, I am sorry that I did not discuss my changes before. I saw in the docs that contributions should be first addressed and discussed in the GitHub issues or Joplin forum. In the future, I will be more aware of that and provide more explicit explanations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added only
s.push(language)
and removeds.push(language.split('-')[0]
because to explicitly display the spellcheck languages with different variants like"en-AU, en-GB, en-US"
instead of"en, en, en"
. This is something that tomasz1986 wanted to see and I agree that from the UI/UX perspective, it is better this way.The changes should not affect
SpellCheckerService.ts
and thestate: AppState
.I might have missed something based on your review, let me know!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are a few other options:
1. Only show the region code when it prevents duplicate values from being added to
s
Another option might be to only include the region code when there are multiple copies of the same language.
For example,
languages = [ 'en-GB', 'en-US' ]
=>s = [ 'en-GB', 'en-US' ]
languages = [ 'en-GB', 'es-MX' ]
=>s = [ 'en', 'es' ]
.2. Remove duplicates
For example,
languages = [ 'en', 'en', 'en' ]
=>s = [ 'en' ]
This is based on one of the list items in "describe what you expected to happen" in the original issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the author of the original issue, I actually like this approach a lot. It would allow for the language list to take less space, so that more title text could be displayed on the screen, which is precious especially on narrower displays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, the second solution is good in terms of usability and reduces clutter. @HahaBill, this is what I was trying to get at: first find out why something was done in a particular way. It was indeed to reduce clutter because putting the language as eg fr-FR or it-IT doesn't help the user.
So the idea would be to keep the clutter to a minimum while solving the original bug report. Actually both solutions 1 or 2 would work but indeed 2 seems better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me, the second solution also looks better than the first one, and everyone seems to lean towards that. The second solution it is! :)
(at sign)laurent22 I see now! That is a really good point and lesson learned. I will keep that in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the solution: