Skip to content

Commit f77a9c2

Browse files
committed
refactor(css): simplify bracket syntax handling and improve lookup element creation
1 parent d57b81d commit f77a9c2

4 files changed

Lines changed: 20 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## [Unreleased]
44

5+
## [1.6.0] - 2025-12-10
6+
7+
- fix css icon lose
8+
- fix completion with two dot
9+
510
## [1.5.4] - 2025-12-10
611

712
- 升级版本号到 1.5.4 并准备发布
@@ -160,7 +165,8 @@
160165
- support a little complex parents selector
161166
- support css selector has pseudo
162167

163-
[Unreleased]: https://github.com/Q-Peppa/react-css-modules-all/compare/v1.5.4...HEAD
168+
[Unreleased]: https://github.com/Q-Peppa/react-css-modules-all/compare/v1.6.0...HEAD
169+
[1.6.0]: https://github.com/Q-Peppa/react-css-modules-all/compare/v1.5.4...v1.6.0
164170
[1.5.4]: https://github.com/Q-Peppa/react-css-modules-all/compare/v1.5.3...v1.5.4
165171
[1.5.3]: https://github.com/Q-Peppa/react-css-modules-all/compare/v1.5.2...v1.5.3
166172
[1.5.2]: https://github.com/Q-Peppa/react-css-modules-all/compare/v1.5.1...v1.5.2

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ pluginGroup = com.peppa.css
44
pluginName = CSS Modules
55
pluginRepositoryUrl = https://github.com/Q-Peppa/react-css-modules-all
66
# SemVer format -> https://semver.org
7-
pluginVersion = 1.5.4
8-
version = 1.5.4
7+
pluginVersion = 1.6.0
8+
version = 1.6.0
99
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1010
pluginSinceBuild=242
1111
# pluginUntilBuild = 242.* # for Supported all version > 231

src/main/kotlin/com/peppa/css/completion/CssModulesClassNameCompletionContributor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ class CssModulesClassNameCompletionContributor : CompletionContributor() {
7373
private fun convertToBracketSyntax(context: InsertionContext, lookupString: String) {
7474
val document = context.editor.document
7575
val dotOffset = context.startOffset - 1
76-
document.replaceString(dotOffset, context.tailOffset, "['$lookupString']")
77-
context.editor.caretModel.moveToOffset(dotOffset + lookupString.length + 4)
76+
document.replaceString(dotOffset, context.tailOffset, "[$lookupString]")
77+
context.editor.caretModel.moveToOffset(context.tailOffset)
7878
}
7979
}
8080

src/main/kotlin/com/peppa/css/completion/QCssModulesUtil.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,15 @@ fun buildLookupElementHelper(
165165
val lookupString = CssEscapeUtil.escapeSpecialCssChars(name)
166166
val lineNumber = (css as CssRuleset).selectors.first().lineNumber
167167
val lookup = if (isNeedWrapByChar) "'$lookupString'" else lookupString
168-
return LookupElementBuilder.createWithSmartPointer(lookup, css).apply {
169-
bold()
170-
withPsiElement(css)
171-
withIcon(AllIcons.Xml.Css_class)
172-
withPresentableText(lookup)
173-
withCaseSensitivity(true)
174-
withTailText(" ".repeat(SpaceSize) + "($location:$lineNumber)", true)
175-
}.let { PrioritizedLookupElement.withPriority(it, CssCompletionUtil.CSS_SELECTOR_SUFFIX_PRIORITY.toDouble()) }
168+
val ele = LookupElementBuilder.createWithSmartPointer(lookup, css)
169+
.bold()
170+
.withPsiElement(css)
171+
.withIcon(AllIcons.Xml.Css_class)
172+
.withPresentableText(lookup)
173+
.withCaseSensitivity(true)
174+
.withTailText(" ".repeat(SpaceSize) + "($location:$lineNumber)", true)
175+
176+
return PrioritizedLookupElement.withPriority(ele, CssCompletionUtil.CSS_SELECTOR_SUFFIX_PRIORITY.toDouble())
176177
}
177178

178179
private fun toGetStylesheetFile(ref: PsiReference?): StylesheetFile? {

0 commit comments

Comments
 (0)