Skip to content

Commit 3507597

Browse files
committed
fix: spellcheck results now have proper spacing
1 parent b388fe4 commit 3507597

File tree

12 files changed

+154
-52
lines changed

12 files changed

+154
-52
lines changed

Assets/com.fluid.simple-spellcheck/Editor/Resources/SpellCheck/Logs.uxml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
name="no-results"
77
class="hide"
88
text="No spelling errors found"
9+
enabledRichText="true"
910
/>
1011
<VisualElement name="log-container" />
1112
</VisualElement>

Assets/com.fluid.simple-spellcheck/Editor/Resources/SpellCheck/Results.uss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
}
44

55
.text-block {
6-
flex-direction: row;
7-
flex-wrap: wrap;
86
margin-bottom: 10px;
97
}
108

Assets/com.fluid.simple-spellcheck/Editor/Resources/SpellCheck/Results.uxml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<VisualElement name="container">
33
<VisualElement name="text" >
44
<TextElement
5+
enabledRichText="true"
56
class="text-block"
67
text="Trigger the spell check API `SpellCheck.Instance.Validate(text)` to see spelling errors."
78
/>

Assets/com.fluid.simple-spellcheck/Editor/Scripts/SpellCheck/SpellCheck.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ public SpellCheckInternal (IEnglishDictionary dic) {
6868
_dic = dic;
6969
}
7070

71-
public IWordSpelling[] Validate (string text) {
72-
return GetWords(text)
73-
.Select(i => new WordSpelling(i, _dic.HasWord(i)))
74-
.ToArray<IWordSpelling>();
71+
public string Validate (string text) {
72+
var words = GetWords(text)
73+
.Select(i => _dic.HasWord(i) ? i : $"<color=red>{i}</color>");
74+
75+
return string.Join(" ", words);
7576
}
7677

7778
public bool IsInvalid (string text) {

Assets/com.fluid.simple-spellcheck/Editor/Scripts/Windows/SpellCheckResults.cs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public static SpellCheckResults GetWindow () {
1414
return window;
1515
}
1616

17-
public static void ShowWindow (IWordSpelling[] results) {
17+
public static void ShowWindow (string text) {
1818
var window = GetWindow();
1919
window.titleContent = new GUIContent("Spell Check");
2020

2121
window.ClearText();
22-
window.ShowText(results);
22+
window.ShowText(text);
2323
}
2424

2525
private void OnEnable () {
@@ -57,24 +57,11 @@ private void OpenSettings () {
5757
Selection.activeObject = SpellCheckSettings.Instance;
5858
}
5959

60-
private void ShowText (IWordSpelling[] results) {
60+
private void ShowText (string text) {
6161
var root = rootVisualElement.Query("text").First();
6262

63-
var textBlock = new VisualElement();
64-
textBlock.AddToClassList("text-block");
65-
root.Add(textBlock);
66-
67-
foreach (var word in results) {
68-
var text = new TextElement {text = $"{word.Text} "};
69-
70-
if (!word.IsValid) {
71-
text.AddToClassList("bad-spelling");
72-
}
73-
74-
textBlock.Add(text);
75-
}
76-
77-
root.Add(textBlock);
63+
var textElement = new TextElement { text = text, enableRichText = true };
64+
root.Add(textElement);
7865
}
7966

8067
public void ClearText () {
@@ -85,7 +72,7 @@ public void ClearText () {
8572
}
8673
}
8774

88-
public void ShowText (string title, IWordSpelling[] text) {
75+
public void ShowText (string title, string text) {
8976
var root = rootVisualElement.Query("text").First();
9077

9178
var elTitle = new TextElement { text = title };

Assets/com.fluid.simple-spellcheck/Tests/Editor/SpellCheckTest.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,11 @@ public void Setup () {
1313
_spellCheck = new SpellCheckInternal(_dic);
1414
}
1515

16-
[Test]
17-
public void It_should_return_the_word_in_an_array () {
18-
var result = _spellCheck.Validate("Lorem");
19-
20-
Assert.AreEqual("Lorem", result[0].Text);
21-
}
22-
2316
[Test]
2417
public void It_should_return_an_error_for_a_mispelled_word () {
2518
var result = _spellCheck.Validate("Lorem");
2619

27-
Assert.AreEqual(false, result[0].IsValid);
20+
Assert.AreEqual("<color=red>Lorem</color>", result);
2821
}
2922

3023
[Test]
@@ -33,7 +26,7 @@ public void It_should_return_success_for_a_properly_spelled_word () {
3326

3427
var result = _spellCheck.Validate("Lorem");
3528

36-
Assert.AreEqual(true, result[0].IsValid);
29+
Assert.AreEqual("Lorem", result);
3730
}
3831
}
3932

Packages/manifest.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
],
1111
"dependencies": {
1212
"clever-crow.nsubstitute": "2.0.3",
13-
"com.unity.collab-proxy": "1.2.16",
14-
"com.unity.ide.rider": "1.1.4",
15-
"com.unity.ide.vscode": "1.1.4",
16-
"com.unity.test-framework": "1.1.11",
17-
"com.unity.textmeshpro": "2.0.1",
18-
"com.unity.timeline": "1.2.10",
13+
"com.unity.collab-proxy": "1.17.2",
14+
"com.unity.ide.rider": "3.0.15",
15+
"com.unity.ide.visualstudio": "2.0.16",
16+
"com.unity.ide.vscode": "1.2.5",
17+
"com.unity.test-framework": "1.1.33",
18+
"com.unity.textmeshpro": "3.0.6",
19+
"com.unity.timeline": "1.7.1",
1920
"com.unity.ugui": "1.0.0",
2021
"com.unity.modules.ai": "1.0.0",
2122
"com.unity.modules.androidjni": "1.0.0",

Packages/packages-lock.json

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
"url": "https://registry.npmjs.org"
99
},
1010
"com.unity.collab-proxy": {
11-
"version": "1.2.16",
11+
"version": "1.17.2",
1212
"depth": 0,
1313
"source": "registry",
14-
"dependencies": {},
14+
"dependencies": {
15+
"com.unity.services.core": "1.0.1"
16+
},
1517
"url": "https://packages.unity.com"
1618
},
1719
"com.unity.ext.nunit": {
@@ -22,34 +24,61 @@
2224
"url": "https://packages.unity.com"
2325
},
2426
"com.unity.ide.rider": {
25-
"version": "1.1.4",
27+
"version": "3.0.15",
28+
"depth": 0,
29+
"source": "registry",
30+
"dependencies": {
31+
"com.unity.ext.nunit": "1.0.6"
32+
},
33+
"url": "https://packages.unity.com"
34+
},
35+
"com.unity.ide.visualstudio": {
36+
"version": "2.0.16",
2637
"depth": 0,
2738
"source": "registry",
2839
"dependencies": {
29-
"com.unity.test-framework": "1.1.1"
40+
"com.unity.test-framework": "1.1.9"
3041
},
3142
"url": "https://packages.unity.com"
3243
},
3344
"com.unity.ide.vscode": {
34-
"version": "1.1.4",
45+
"version": "1.2.5",
3546
"depth": 0,
3647
"source": "registry",
3748
"dependencies": {},
3849
"url": "https://packages.unity.com"
3950
},
51+
"com.unity.nuget.newtonsoft-json": {
52+
"version": "3.0.2",
53+
"depth": 2,
54+
"source": "registry",
55+
"dependencies": {},
56+
"url": "https://packages.unity.com"
57+
},
58+
"com.unity.services.core": {
59+
"version": "1.4.2",
60+
"depth": 1,
61+
"source": "registry",
62+
"dependencies": {
63+
"com.unity.modules.unitywebrequest": "1.0.0",
64+
"com.unity.nuget.newtonsoft-json": "3.0.2",
65+
"com.unity.modules.androidjni": "1.0.0"
66+
},
67+
"url": "https://packages.unity.com"
68+
},
4069
"com.unity.test-framework": {
41-
"version": "1.1.11",
70+
"version": "1.1.33",
4271
"depth": 0,
4372
"source": "registry",
4473
"dependencies": {
45-
"com.unity.ext.nunit": "1.0.0",
74+
"com.unity.ext.nunit": "1.0.6",
4675
"com.unity.modules.imgui": "1.0.0",
4776
"com.unity.modules.jsonserialize": "1.0.0"
4877
},
4978
"url": "https://packages.unity.com"
5079
},
5180
"com.unity.textmeshpro": {
52-
"version": "2.0.1",
81+
"version": "3.0.6",
5382
"depth": 0,
5483
"source": "registry",
5584
"dependencies": {
@@ -58,10 +87,15 @@
5887
"url": "https://packages.unity.com"
5988
},
6089
"com.unity.timeline": {
61-
"version": "1.2.10",
90+
"version": "1.7.1",
6291
"depth": 0,
6392
"source": "registry",
64-
"dependencies": {},
93+
"dependencies": {
94+
"com.unity.modules.director": "1.0.0",
95+
"com.unity.modules.animation": "1.0.0",
96+
"com.unity.modules.audio": "1.0.0",
97+
"com.unity.modules.particlesystem": "1.0.0"
98+
},
6599
"url": "https://packages.unity.com"
66100
},
67101
"com.unity.ugui": {

ProjectSettings/MemorySettings.asset

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!387306366 &1
4+
MemorySettings:
5+
m_ObjectHideFlags: 0
6+
m_EditorMemorySettings:
7+
m_MainAllocatorBlockSize: -1
8+
m_ThreadAllocatorBlockSize: -1
9+
m_MainGfxBlockSize: -1
10+
m_ThreadGfxBlockSize: -1
11+
m_CacheBlockSize: -1
12+
m_TypetreeBlockSize: -1
13+
m_ProfilerBlockSize: -1
14+
m_ProfilerEditorBlockSize: -1
15+
m_BucketAllocatorGranularity: -1
16+
m_BucketAllocatorBucketsCount: -1
17+
m_BucketAllocatorBlockSize: -1
18+
m_BucketAllocatorBlockCount: -1
19+
m_ProfilerBucketAllocatorGranularity: -1
20+
m_ProfilerBucketAllocatorBucketsCount: -1
21+
m_ProfilerBucketAllocatorBlockSize: -1
22+
m_ProfilerBucketAllocatorBlockCount: -1
23+
m_TempAllocatorSizeMain: -1
24+
m_JobTempAllocatorBlockSize: -1
25+
m_BackgroundJobTempAllocatorBlockSize: -1
26+
m_JobTempAllocatorReducedBlockSize: -1
27+
m_TempAllocatorSizeGIBakingWorker: -1
28+
m_TempAllocatorSizeNavMeshWorker: -1
29+
m_TempAllocatorSizeAudioWorker: -1
30+
m_TempAllocatorSizeCloudWorker: -1
31+
m_TempAllocatorSizeGfx: -1
32+
m_TempAllocatorSizeJobWorker: -1
33+
m_TempAllocatorSizeBackgroundWorker: -1
34+
m_TempAllocatorSizePreloadManager: -1
35+
m_PlatformMemorySettings: {}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!114 &1
4+
MonoBehaviour:
5+
m_ObjectHideFlags: 61
6+
m_CorrespondingSourceObject: {fileID: 0}
7+
m_PrefabInstance: {fileID: 0}
8+
m_PrefabAsset: {fileID: 0}
9+
m_GameObject: {fileID: 0}
10+
m_Enabled: 1
11+
m_EditorHideFlags: 0
12+
m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0}
13+
m_Name:
14+
m_EditorClassIdentifier:
15+
m_EnablePreReleasePackages: 0
16+
m_EnablePackageDependencies: 0
17+
m_AdvancedSettingsExpanded: 1
18+
m_ScopedRegistriesSettingsExpanded: 1
19+
m_SeeAllPackageVersions: 0
20+
m_DismissPreviewPackagesInUse: 0
21+
oneTimeWarningShown: 0
22+
m_Registries:
23+
- m_Id: main
24+
m_Name:
25+
m_Url: https://packages.unity.com
26+
m_Scopes: []
27+
m_IsDefault: 1
28+
m_Capabilities: 7
29+
- m_Id: scoped:NPM
30+
m_Name: NPM
31+
m_Url: https://registry.npmjs.org
32+
m_Scopes:
33+
- clever-crow
34+
m_IsDefault: 0
35+
m_Capabilities: 0
36+
m_UserSelectedRegistryName:
37+
m_UserAddingNewScopedRegistry: 0
38+
m_RegistryInfoDraft:
39+
m_Modified: 0
40+
m_ErrorMessage:
41+
m_UserModificationsInstanceId: -854
42+
m_OriginalInstanceId: -856
43+
m_LoadAssets: 0

0 commit comments

Comments
 (0)