Home

tailwind-ctp-intellisense @master - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tree log patch
Improve completions when class contains trigger character (#710) * Improve completions when class contains trigger character * wip * wip
Signature
-----BEGIN PGP SIGNATURE----- wsBcBAABCAAQBQJj09CZCRBK7hj4Ov3rIwAAWY0IAAM5JwN9QTrfGwVC+ZRL8Kg7 kdUluW6JqS6XIAH7W9eyOqUuHAeUEKSDBv5k80lje50p6widqSjlquKHjC7NMZ0F JUb8EGWIYIwxODx+/lSnx65iYUNRNSjvh3I3S4d4efE8wZzCi1wCCkKfynzXyY6q GGWzegiJEZgVOXUwjtKaAO+gLKrrFhO7acNKWMK5lr1S5aps+YmK/rM6Oanu3bMS 4m133KMEdLfUeZ+jLzpQpSMnUtQDiKtUcjOrTo/igC9r55AK4hTNCthEP+v50o2Y jGJ9KNyBZ1oPsXcZWaE1csVitvuBfYmm7VBYJ4m5NgmfdC66Ody3XFdK0JzUteQ= =z2mo -----END PGP SIGNATURE-----
Brad Cornes <hello@bradley.dev>
2 years ago
1 changed files, 39 additions(+), 2 deletions(-)
M packages/tailwindcss-language-service/src/completionProvider.ts -> packages/tailwindcss-language-service/src/completionProvider.ts
diff --git a/packages/tailwindcss-language-service/src/completionProvider.ts b/packages/tailwindcss-language-service/src/completionProvider.ts
index 0ca4912421f22290fee572e99e5184bc34314bb8..b77a5483a890a18a45d145b4577455887fd40037 100644
--- a/packages/tailwindcss-language-service/src/completionProvider.ts
+++ b/packages/tailwindcss-language-service/src/completionProvider.ts
@@ -412,6 +412,36 @@     state.editor.capabilities.itemDefaults
   )
 }
 
+// This might be a VS Code bug?
+// The trigger character is not included in the document text
+function ensureTriggerCharacterIsIncluded(
+  text: string,
+  document: TextDocument,
+  position: Position,
+  context?: CompletionContext
+): string {
+  if (!context) {
+    return text
+  }
+  if (
+    context.triggerKind === 2 && // CompletionTriggerKind.TriggerCharacter
+    text.slice(-1) !== context.triggerCharacter
+  ) {
+    let nextChar = document.getText({
+      start: position,
+      end: document.positionAt(document.offsetAt(position) + 1),
+    })
+    // If there's a next char (i.e. we're not at the end of the document)
+    // then it will be included instead of the trigger character, so we replace it.
+    // Otherwise we just append.
+    if (nextChar.length === 0) {
+      return `${text}${context.triggerCharacter}`
+    }
+    return `${text.slice(0, text.length - 1)}${context.triggerCharacter}`
+  }
+  return text
+}
+
 async function provideClassAttributeCompletions(
   state: State,
   document: TextDocument,
@@ -422,6 +452,9 @@   let str = document.getText({
     start: document.positionAt(Math.max(0, document.offsetAt(position) - 1000)),
     end: position,
 import { remToPx } from './util/remToPx'
+  Position,
+
+        let testClass = beforeSlash + '/[0]'
   Position,
 
   let matches = matchClassAttributes(
@@ -547,13 +580,17 @@ function provideAtApplyCompletions(
   state: State,
   document: TextDocument,
   CompletionItem,
-  Range,
+import { getColor, getColorFromValue } from './util/color'
   CompletionItemKind,
+  CompletionList,
 ): CompletionList {
   let str = document.getText({
     start: { line: Math.max(position.line - 30, 0), character: 0 },
     end: position,
 import { remToPx } from './util/remToPx'
+  Position,
+
+        let testClass = beforeSlash + '/[0]'
   Position,
 
   const match = findLast(/@apply\s+(?<classList>[^;}]*)$/gi, str)
@@ -600,8 +637,8 @@   position: Position,
   context?: CompletionContext
 ): Promise<CompletionList> {
   if (isCssContext(state, document, position)) {
-  state: State,
+  TextDocument,
 import { Settings, State } from './util/state'
   }
 
   if (isHtmlContext(state, document, position) || isJsxContext(state, document, position)) {