Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#528 closed defect (fixed)

Chinese text input in tags doesn't work as expected

Reported by: d@… Owned by: framm
Priority: major Milestone:
Component: Core Version: tested
Keywords: Cc:


When trying to enter Chinese text in a tag the autocomplete doesn't work as expected. This is on Windows with Metal theme, not sure if other platforms have the same problem.

Things required to reproduce...
1) A Chinese IME installed, the standard windows Pinyin one will do.
2) An open dataset with Chinese in, e.g. Hangzhou at 30.274/120.158

Steps to reproduce
1) Choose an object with no name
2) Click Add under properties to add a tag
3) Type name in Key
4) In Value, switch the Chinese input, shift-alt or ctrl-space are defaults depending on what language mode you are in, alternatively use the language bar...
5) Start typing a name that exists in the data, such as 文三路 (wen san lu)...

typing wen shows the characters wen displayed strong highlighted in the input box with the character chooser below it, choose 2 for 文, it'll then autocomplete with something that starts with 文, e.g. 文一西路 (wen yi xi lu), at this point, 文 is unselected, but the remaining characters are selected (highlighted), we should be able to just type 三 (san) at this point to enter the next character, typing san, shows the characters san appear after the entire autocompleted string, choosing 1 from the IME, for 三 gives us 文一西路三, all we've typed is wen and san, the first and last characters, the bit in between is autocomplete that hasn't been overwritten by 三. So, seeing this, I delete the 三 (san) off the end, put the cursor directly after the 文 (wen) and try to type 三 (san) here, inserting between 文 and 一西路 that came from auto completion... What I get after typing 's' is 文s一西路 with the s with a strong highlight and the 一西路 with a lighter highlight, looking OK, then when continue and type 'a' after the 's' what I get is 文s一西sa, with 一西 light highlighted, the 'sa' at the end strong highlighted, there are now two 's', only one was typed, also, of the three characters from autocomplete, 一 (yi (one)) 西 (xi (west)) and 路 (lu (road)) only two are left, the last one, 路 (lu), has vanished... Complete the entry of 三 and it ends up as 文s一西三...

I think that's enough to get the idea, make it somewhat interesting to work with...

Attachments (0)

Change History (6)

comment:1 Changed 11 years ago by d@…

I'm wondering if the key bit is that JOSM seems to be capturing the keystrokes, with most other software, the entered text appears in the IME's text box, only the selected character is then placed into the applications text box. This didn't seem to be as big a problem in older 0.5/modeless versions of JOSM...

Also, after experiencing this problem, I've noticed that the autocomplete functionality now also has some more problems with non-chinese input, type in a value, move the cursor back through the typed text and try to insert something, e.g. The at the beginning, the first character typed triggers the rest of the text following it to be highlighted as if it was from autocomplete with the cursor placed at the end of the string, even this is a value that doesn't exist anywhere, the second keystroke overwrites the remainder of the text as you'd expect from the highlighting. Moving the cursor back to the text entry point removes the highlighting and allows you to enter the second character, but the cursor positioning and highlighting happen again, so the same needs to be done before the third character. I'll try restart JOSM and see if this is happening without trying to enter Chinese text first, if it does, I'll raise a separate ticket for this problem.

comment:2 Changed 11 years ago by Gabriel Ebner <ge@…>

Okay, I just tried using scim's "smart pinyin" IM and java 6. Adding the first name=文三路 tag works just fine. However when I try to add a second name tag, things get hairy: If I write 文三路 in one go,I'll get 文三文三路. If I just write the first character 文, JOSM will autocomplete that to 文三路 (even though it shows other weird characters while typing that in...).

And all the while, we get these scary exceptions:

Exception occurred during event dispatching:
java.lang.IllegalArgumentException: Invalid substring range
        at java.text.AttributedString$AttributedStringIterator.<init>(
        at java.text.AttributedString.getIterator(
        at javax.swing.text.Utilities.drawComposedText(
        at javax.swing.text.PlainView.drawElement(
        at javax.swing.text.PlainView.drawLine(
        at javax.swing.text.PlainView.paint(
        at javax.swing.text.FieldView.paint(
        at javax.swing.plaf.basic.BasicTextUI$RootView.paint(
        at javax.swing.plaf.basic.BasicTextUI.paintSafely(
        at javax.swing.plaf.basic.BasicTextUI.paint(
        at javax.swing.plaf.basic.BasicTextUI.update(
        at javax.swing.JComponent.paintComponent(
        at javax.swing.JComponent.paint(
        at javax.swing.JComponent.paintToOffscreen(
        at javax.swing.BufferStrategyPaintManager.paint(
        at javax.swing.RepaintManager.paint(
        at javax.swing.JComponent._paintImmediately(
        at javax.swing.JComponent.paintImmediately(
        at javax.swing.RepaintManager.paintDirtyRegions(
        at javax.swing.RepaintManager.paintDirtyRegions(
        at javax.swing.RepaintManager.seqPaintDirtyRegions(
        at javax.swing.SystemEventQueueUtilities$
        at java.awt.event.InvocationEvent.dispatch(
        at java.awt.EventQueue.dispatchEvent(
        at java.awt.EventDispatchThread.pumpOneEventForFilters(
        at java.awt.EventDispatchThread.pumpEventsForFilter(
        at java.awt.EventDispatchThread.pumpEventsForFilter(
        at java.awt.Dialog$
        at java.awt.Dialog$
        at Method)
        at java.awt.Component.setVisible(
        at java.awt.Window.setVisible(
        at java.awt.Dialog.setVisible(
        at org.openstreetmap.josm.gui.dialogs.PropertiesDialog.add(
        at org.openstreetmap.josm.gui.dialogs.PropertiesDialog$10.actionPerformed(
        at javax.swing.AbstractButton.fireActionPerformed(
        at javax.swing.AbstractButton$Handler.actionPerformed(
        at javax.swing.DefaultButtonModel.fireActionPerformed(
        at javax.swing.DefaultButtonModel.setPressed(
        at javax.swing.plaf.basic.BasicButtonListener$Actions.actionPerformed(
        at javax.swing.SwingUtilities.notifyAction(
        at javax.swing.JComponent.processKeyBinding(
        at javax.swing.KeyboardManager.fireBinding(
        at javax.swing.KeyboardManager.fireKeyboardAction(
        at javax.swing.JComponent.processKeyBindingsForAllComponents(
        at javax.swing.JComponent.processKeyBindings(
        at javax.swing.JComponent.processKeyEvent(
        at java.awt.Component.processEvent(
        at java.awt.Container.processEvent(
        at java.awt.Component.dispatchEventImpl(
        at java.awt.Container.dispatchEventImpl(
        at java.awt.Component.dispatchEvent(
        at java.awt.KeyboardFocusManager.redispatchEvent(
        at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(
        at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(
        at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(
        at java.awt.DefaultKeyboardFocusManager.dispatchEvent(
        at java.awt.Component.dispatchEventImpl(
        at java.awt.Container.dispatchEventImpl(
        at java.awt.Window.dispatchEventImpl(
        at java.awt.Component.dispatchEvent(
        at java.awt.EventQueue.dispatchEvent(
        at java.awt.EventDispatchThread.pumpOneEventForFilters(
        at java.awt.EventDispatchThread.pumpEventsForFilter(
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(
        at java.awt.EventDispatchThread.pumpEvents(
        at java.awt.EventDispatchThread.pumpEvents(

Anybody know both java and IMs?

As for your second question, I can confirm weird behaviour. Autocompletion is quite a hacky feature with all sorts of warts to make it usable (if any swing guru is listening, is there any right way to do it?).

comment:4 Changed 11 years ago by anonymous

Does this still happen in new JOSM versions? The AtoCompletion has been fixed a lot to remove many problems.

comment:5 Changed 11 years ago by anonymous

Resolution: fixed
Status: newclosed

Closing. Should be fixed by autocompletion correction.

comment:6 Changed 10 years ago by dqwmayinng

Version: release

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain framm.
as The resolution will be set.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.