Tamil combining marks are counted as extra cells, placing the input cursor too far right
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 65/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- csharp, powershell
- Ambito
- cli, developer-experience
Direzione di ricerca
The issue is in the LengthInBufferCells method in Render.Helper.cs lines 50-121. Start by examining how it counts cells for each character; Tamil combining marks (U+0BCD, U+0BC0) are currently counted as one cell each, but should be zero-width in Terminal's graphemes mode. Look at the char overload and the string overload. Test the fix by running the provided diagnostic script and checking cursor placement in Windows Terminal with the example Tamil text.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues, especially the pinned issues.
Exception report
N/A. This is incorrect cursor positioning, not a crash.
Screenshot
No image attached. This text illustration describes the observed symptom; | represents the cursor:
Expected: வணக்கம் இப்படி இருக்கீங்க ?|
Actual: வணக்கம் இப்படி இருக்கீங்க ? |
The six spaces illustrate the visual cursor gap, not spaces that should be inserted into the input.
Environment data
PS Version: 7.6.6
PS HostName: ConsoleHost
PSReadLine Version: 2.4.5
PSReadLine EditMode: Windows (fresh diagnostic process)
OS reported by PowerShell: Microsoft Windows 10.0.26300
Windows Terminal Version: 1.24.11911.0
Windows Terminal text measurement: graphemes
BufferWidth / BufferHeight: not captured from the interactive reproduction
The interactive symptom occurred in Windows Terminal. The width-helper diagnostic also reproduces in a noninteractive PowerShell process.
Steps to reproduce
Summary
Tamil text renders correctly, but the input cursor appears several columns to the right of the final character. For வணக்கம் இப்படி இருக்கீங்க ?, PSReadLine calculates 27 cells while Terminal's graphemes mode allocates 21 cells.
Interactive reproduction
- Open PowerShell with PSReadLine 2.4.5 inside Windows Terminal.
- Set the top-level Terminal setting
"compatibility.textMeasurement": "graphemes"and open a new terminal session. - Use a font/fallback combination that renders Tamil correctly.
- Type or paste
வணக்கம் இப்படி இருக்கீங்க ?at the prompt, without a trailing space. - Do not press Enter. Observe the cursor at the end of the input.
This concerns interactive command-line input, not cursor placement after a command prints output.
The observed font setting was "face": "CaskaydiaCove Nerd Font Mono, Tamil Terminal Mono". The second font is a custom Tamil-only fallback with metrics matching the primary: 1200 units per cell, 2048 units per em, ascent 1900, descent 480, and line gap 0. Shaping and advances were checked with DirectWrite. Glyph overlap was resolved before observing the cursor issue.
The following diagnostic does not require these fonts or any font installation.
Font-independent diagnostic
This only reads PSReadLine's calculation; it does not patch code or change settings:
Import-Module PSReadLine
$text = 'வணக்கம் இப்படி இருக்கீங்க ?'
$method = [Microsoft.PowerShell.PSConsoleReadLine].GetMethod(
'LengthInBufferCells',
[Reflection.BindingFlags]'Static,NonPublic',
$null,
[Type[]]@([string]),
$null
)
if ($null -eq $method) {
throw 'The expected internal width helper was not found in this version.'
}
[pscustomobject]@{
UTF16CodeUnits = $text.Length
PSReadLineCells = $method.Invoke($null, [object[]]@($text))
ExpectedTerminalCells = 21
}
Actual output on PSReadLine 2.4.5:
UTF16CodeUnits PSReadLineCells ExpectedTerminalCells
-------------- --------------- ---------------------
27 27 21
All characters in this example are in the BMP, so code-unit and code-point counts coincide; neither equals the displayed cell count.
Version 2.4.5 is currently the latest GitHub release. Existing and pinned issues were searched for Tamil, Indic, combining marks, graphemes, and LengthInBufferCells.
Expected behavior
The cursor should appear immediately after ?, at 21 input cells plus the prompt width. Tamil nonspacing marks should not create extra cursor columns.
Useful regression cases for Terminal's graphemes mode:
| Input | Expected cells |
|---|---|
ABC |
3 |
க |
1 |
க் |
1 |
கீ |
1 |
கா |
2 |
வணக்கம் இப்படி இருக்கீங்க ? |
21 |
Please distinguish nonspacing marks (Mn) from spacing vowel signs (Mc). Giving every Unicode mark zero width would also be incorrect for this mode: கா uses two cells. These examples are not a complete proposal for arbitrary grapheme handling.
Actual behavior
The cursor appears six columns too far right. PSReadLine calculates 27 cells instead of 21.
| Text | UTF-16 code units | Terminal cells |
|---|---|---|
வணக்கம் |
7 | 5 |
இப்படி |
6 | 5 |
இருக்கீங்க |
10 | 7 |
| Three separating spaces | 3 | 3 |
? |
1 | 1 |
| Total | 27 | 21 |
The difference comes from five U+0BCD TAMIL SIGN VIRAMA (pulli) marks and one U+0BC0 TAMIL VOWEL SIGN II, all of category Mn.
For example, க் is a consonant plus a pulli. It occupies one cell, but the helper counts two code units separately.
Relevant code
In PSReadLine 2.4.5, Render.Helper.cs:
- The string overload sums
LengthInBufferCells(char)for each code unit. - The char overload checks control characters and East Asian wide ranges, then returns one or two cells.
- Tamil nonspacing marks fall through to the one-cell result; there is no zero-width result for them.
The diagnostic calls the internal Microsoft.PowerShell.PSConsoleReadLine.LengthInBufferCells method, not the similarly named PowerShell host API.
Expected widths refer to Terminal's graphemes mode: CodepointWidthDetector.cpp.
Related issue
#1223 concerns double-width characters at the right edge of a line. This case concerns Tamil nonspacing marks in ordinary input, even far from a line boundary.
- Lingua principale
- C#
- Stelle
- 4.4k
- Fork
- 341
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di PowerShell/PSReadLine
-
Needs-Triage :mag:
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
PowerShell/PSReadLine#5205 ·
-
Needs-Triage :mag:
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
PowerShell/PSReadLine#5195 ·
-
Needs-Triage :mag:
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
PowerShell/PSReadLine#5121 ·
-
Needs-Triage :mag:
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
PowerShell/PSReadLine#5045 ·
-
Area-CommandHelp Issue-Enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
PowerShell/PSReadLine#3470 · 3 reazioni ·
Tutte le issue di PowerShell/PSReadLine
Issue simili
-
effort:S P3 refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
nightscout/nocturne#1532 ·
-
core dependencies
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
C#/.NET Roslyn LSP Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Suspicious code fragments Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
DotNetNext/SqlSugar#1458 ·